(()=>{var La=Object.defineProperty,Ia=Object.defineProperties;var Ra=Object.getOwnPropertyDescriptors;var oi=Object.getOwnPropertySymbols;var Nr=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable;var fs=(e,t,i)=>t in e?La(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,P=(e,t)=>{for(var i in t||(t={}))Nr.call(t,i)&&fs(e,i,t[i]);if(oi)for(var i of oi(t))Fr.call(t,i)&&fs(e,i,t[i]);return e},Z=(e,t)=>Ia(e,Ra(t));var Ur=(e,t)=>{var i={};for(var s in e)Nr.call(e,s)&&t.indexOf(s)<0&&(i[s]=e[s]);if(e!=null&&oi)for(var s of oi(e))t.indexOf(s)<0&&Fr.call(e,s)&&(i[s]=e[s]);return i};var ps=(e,t,i)=>(fs(e,typeof t!="symbol"?t+"":t,i),i);var I=(e,t,i)=>new Promise((s,r)=>{var n=l=>{try{a(i.next(l))}catch(h){r(h)}},o=l=>{try{a(i.throw(l))}catch(h){r(h)}},a=l=>l.done?s(l.value):Promise.resolve(l.value).then(n,o);a((i=i.apply(e,t)).next())});var At=class{constructor(t={}){t=Object.assign({resolveTimeout:null,resolveValue:!0,rejectTimeout:null,rejectValue:!1},t),this._promise=new Promise((o,a)=>{this.resolve=o,this.reject=a}),this.then=this._promise.then.bind(this._promise),this.catch=this._promise.catch.bind(this._promise),this.finally=this._promise.finally.bind(this._promise),this[Symbol.toStringTag]="Promise";let{resolveTimeout:i,resolveValue:s,rejectTimeout:r,rejectValue:n}=t;i&&setTimeout(()=>this.resolve(s),i),r&&setTimeout(()=>this.reject(n),r)}};var $r="layer";function Vr(e,t){document.dispatchEvent(new CustomEvent("doofinder.register",{detail:{name:e,entrypoint:t}}))}var Oe=e=>typeof e=="function"?e:function(){return e},Oa=typeof self!="undefined"?self:null,He=typeof window!="undefined"?window:null,ie=Oa||He||ie,Ha="2.0.0",Rt={connecting:0,open:1,closing:2,closed:3},Da=1e4,Ma=1e3,bt={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},Nt={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},ms={longpoll:"longpoll",websocket:"websocket"},Na={complete:4},ai=class{constructor(e,t,i,s){this.channel=e,this.event=t,this.payload=i||function(){return{}},this.receivedResp=null,this.timeout=s,this.timeoutTimer=null,this.recHooks=[],this.sent=!1}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload(),ref:this.ref,join_ref:this.channel.joinRef()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}matchReceive({status:e,response:t,_ref:i}){this.recHooks.filter(s=>s.status===e).forEach(s=>s.callback(t))}cancelRefEvent(){!this.refEvent||this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},jr=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=null,this.tries=0}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}},Fa=class{constructor(e,t,i){this.state=bt.closed,this.topic=e,this.params=Oe(t||{}),this.socket=i,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new ai(this,Nt.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new jr(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=bt.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this.joinPush.receive("error",()=>{this.state=bt.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic} ${this.joinRef()}`),this.state=bt.closed,this.socket.remove(this)}),this.onError(s=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,s),this.isJoining()&&this.joinPush.reset(),this.state=bt.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic} (${this.joinRef()})`,this.joinPush.timeout),new ai(this,Nt.leave,Oe({}),this.timeout).send(),this.state=bt.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(Nt.reply,(s,r)=>{this.trigger(this.replyEventName(r),s)})}join(e=this.timeout){if(this.joinedOnce)throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush}onClose(e){this.on(Nt.close,e)}onError(e){return this.on(Nt.error,t=>e(t))}on(e,t){let i=this.bindingRef++;return this.bindings.push({event:e,ref:i,callback:t}),i}off(e,t){this.bindings=this.bindings.filter(i=>!(i.event===e&&(typeof t=="undefined"||t===i.ref)))}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,i=this.timeout){if(t=t||{},!this.joinedOnce)throw new Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let s=new ai(this,e,function(){return t},i);return this.canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=bt.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(Nt.close,"leave")},i=new ai(this,Nt.leave,Oe({}),e);return i.receive("ok",()=>t()).receive("timeout",()=>t()),i.send(),this.canPush()||i.trigger("ok",{}),i}onMessage(e,t,i){return t}isMember(e,t,i,s){return this.topic!==e?!1:s&&s!==this.joinRef()?(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:i,joinRef:s}),!1):!0}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=bt.joining,this.joinPush.resend(e))}trigger(e,t,i,s){let r=this.onMessage(e,t,i,s);if(t&&!r)throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");let n=this.bindings.filter(o=>o.event===e);for(let o=0;o{let a=this.parseJSON(e.responseText);o&&o(a)},n&&(e.ontimeout=n),e.onprogress=()=>{},e.send(s),e}static xhrRequest(e,t,i,s,r,n,o,a){return e.open(t,i,!0),e.timeout=n,e.setRequestHeader("Content-Type",s),e.onerror=()=>a&&a(null),e.onreadystatechange=()=>{if(e.readyState===Na.complete&&a){let l=this.parseJSON(e.responseText);a(l)}},o&&(e.ontimeout=o),e.send(r),e}static parseJSON(e){if(!e||e==="")return null;try{return JSON.parse(e)}catch(t){return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let i=[];for(var s in e){if(!Object.prototype.hasOwnProperty.call(e,s))continue;let r=t?`${t}[${s}]`:s,n=e[s];typeof n=="object"?i.push(this.serialize(n,r)):i.push(encodeURIComponent(r)+"="+encodeURIComponent(n))}return i.join("&")}static appendParams(e,t){if(Object.keys(t).length===0)return e;let i=e.match(/\?/)?"&":"?";return`${e}${i}${this.serialize(t)}`}},Ua=e=>{let t="",i=new Uint8Array(e),s=i.byteLength;for(let r=0;rthis.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(new RegExp("(.*)/"+ms.websocket),"$1/"+ms.longpoll)}endpointURL(){return li.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,i){this.close(e,t,i),this.readyState=Rt.connecting}ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===Rt.open||this.readyState===Rt.connecting}poll(){this.ajax("GET","application/json",null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:i,messages:s}=e;this.token=i}else t=0;switch(t){case 200:s.forEach(r=>{setTimeout(()=>this.onmessage({data:r}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=Rt.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw new Error(`unhandled poll status ${t}`)}})}send(e){typeof e!="string"&&(e=Ua(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST","application/x-ndjson",e.join(` `),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=!1,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(e,t,i){for(let r of this.reqs)r.abort();this.readyState=Rt.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent!="undefined"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,i,s,r){let n,o=()=>{this.reqs.delete(n),s()};n=li.request(e,this.endpointURL(),t,i,this.timeout,o,a=>{this.reqs.delete(n),this.isActive()&&r(a)}),this.reqs.add(n)}};var hi={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,r,n,o]=JSON.parse(e);return t({join_ref:i,ref:s,topic:r,event:n,payload:o})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:r,payload:n}=e,o=this.META_LENGTH+t.length+i.length+r.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),h=0;l.setUint8(h++,this.KINDS.push),l.setUint8(h++,t.length),l.setUint8(h++,i.length),l.setUint8(h++,r.length),l.setUint8(h++,s.length),Array.from(t,f=>l.setUint8(h++,f.charCodeAt(0))),Array.from(i,f=>l.setUint8(h++,f.charCodeAt(0))),Array.from(r,f=>l.setUint8(h++,f.charCodeAt(0))),Array.from(s,f=>l.setUint8(h++,f.charCodeAt(0)));var d=new Uint8Array(a.byteLength+n.byteLength);return d.set(new Uint8Array(a),0),d.set(new Uint8Array(n),a.byteLength),d.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),r=t.getUint8(2),n=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+r));o=o+r;let h=i.decode(e.slice(o,o+n));o=o+n;let d=e.slice(o,e.byteLength);return{join_ref:a,ref:null,topic:l,event:h,payload:d}},decodeReply(e,t,i){let s=t.getUint8(1),r=t.getUint8(2),n=t.getUint8(3),o=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=i.decode(e.slice(a,a+s));a=a+s;let h=i.decode(e.slice(a,a+r));a=a+r;let d=i.decode(e.slice(a,a+n));a=a+n;let f=i.decode(e.slice(a,a+o));a=a+o;let b=e.slice(a,e.byteLength),v={status:f,response:b};return{join_ref:l,ref:h,topic:d,event:Nt.reply,payload:v}},decodeBroadcast(e,t,i){let s=t.getUint8(1),r=t.getUint8(2),n=this.HEADER_LENGTH+2,o=i.decode(e.slice(n,n+s));n=n+s;let a=i.decode(e.slice(n,n+r));n=n+r;let l=e.slice(n,e.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},Br=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||Da,this.transport=t.transport||ie.WebSocket||De,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||ie&&ie.sessionStorage,this.establishedConnections=0,this.defaultEncoder=hi.encode.bind(hi),this.defaultDecoder=hi.decode.bind(hi),this.closeWasClean=!1,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==De?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;He&&He.addEventListener&&(He.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),He.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,500,1e3,2e3][s-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(s,r,n)=>{console.log(`${s}: ${r}`,n)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=Oe(t.params||{}),this.endPoint=`${e}/${ms.websocket}`,this.vsn=t.vsn||Ha,this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new jr(()=>{this.teardown(()=>this.connect())},this.reconnectAfterMs)}getLongPollTransport(){return De}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=li.appendParams(li.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return e.charAt(0)!=="/"?e:e.charAt(1)==="/"?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,i){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,i)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=Oe(e)),!(this.conn&&!this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==De?this.connectWithFallback(De,this.longPollFallbackMs):this.transportConnect())}log(e,t,i){this.logger&&this.logger(e,t,i)}hasLogger(){return this.logger!==null}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),i=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let s=this.onMessage(r=>{r.ref===t&&(this.off([s]),e(Date.now()-i))});return!0}transportConnect(){this.connectClock++,this.closeWasClean=!1,this.conn=new this.transport(this.endPointURL()),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,this.conn.onopen=()=>this.onConnOpen(),this.conn.onerror=e=>this.onConnError(e),this.conn.onmessage=e=>this.onConnMessage(e),this.conn.onclose=e=>this.onConnClose(e)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){clearTimeout(this.fallbackTimer);let i=!1,s=!0,r,n,o=a=>{this.log("transport",`falling back to ${e.name}...`,a),this.off([r,n]),s=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${e.name}`))return o("memorized");this.fallbackTimer=setTimeout(o,t),n=this.onError(a=>{this.log("transport","error",a),s&&!i&&(clearTimeout(this.fallbackTimer),o(a))}),this.onOpen(()=>{if(i=!0,!s)return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${e.name}`,"true"),this.log("transport",`established ${e.name} fallback`);clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,t),this.ping(a=>{this.log("transport","connected to primary after",a),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`${this.transport.name} connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.resetHeartbeat(),this.stateChangeCallbacks.open.forEach(([,e])=>e())}heartbeatTimeout(){this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection"),this.triggerChanError(),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),Ma,"heartbeat timeout"))}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,i){if(!this.conn)return e&&e();let s=this.connectClock;this.waitForBufferDone(()=>{s===this.connectClock&&(this.conn&&(t?this.conn.close(t,i||""):this.conn.close()),this.waitForSocketClosed(()=>{s===this.connectClock&&(this.conn&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e())}))})}waitForBufferDone(e,t=1){if(t===5||!this.conn||!this.conn.bufferedAmount){e();return}setTimeout(()=>{this.waitForBufferDone(e,t+1)},150*t)}waitForSocketClosed(e,t=1){if(t===5||!this.conn||this.conn.readyState===Rt.closed){e();return}setTimeout(()=>{this.waitForSocketClosed(e,t+1)},150*t)}onConnClose(e){let t=e&&e.code;this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(),this.clearHeartbeats(),!this.closeWasClean&&t!==1e3&&this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(([,i])=>i(e))}onConnError(e){this.hasLogger()&&this.log("transport",e);let t=this.transport,i=this.establishedConnections;this.stateChangeCallbacks.error.forEach(([,s])=>{s(e,t,i)}),(t===this.transport||i>0)&&this.triggerChanError()}triggerChanError(){this.channels.forEach(e=>{e.isErrored()||e.isLeaving()||e.isClosed()||e.trigger(Nt.error)})}connectionState(){switch(this.conn&&this.conn.readyState){case Rt.connecting:return"connecting";case Rt.open:return"open";case Rt.closing:return"closing";default:return"closed"}}isConnected(){return this.connectionState()==="open"}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([i])=>e.indexOf(i)===-1)}channel(e,t={}){let i=new Fa(e,t,this);return this.channels.push(i),i}push(e){if(this.hasLogger()){let{topic:t,event:i,payload:s,ref:r,join_ref:n}=e;this.log("push",`${t} ${i} (${n}, ${r})`,s)}this.isConnected()?this.encode(e,t=>this.conn.send(t)):this.sendBuffer.push(()=>this.encode(e,t=>this.conn.send(t)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){this.pendingHeartbeatRef&&!this.isConnected()||(this.pendingHeartbeatRef=this.makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs))}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,t=>{let{topic:i,event:s,payload:r,ref:n,join_ref:o}=t;n&&n===this.pendingHeartbeatRef&&(this.clearHeartbeats(),this.pendingHeartbeatRef=null,this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)),this.hasLogger()&&this.log("receive",`${r.status||""} ${i} ${s} ${n&&"("+n+")"||""}`,r);for(let a=0;ai.topic===e&&(i.isJoined()||i.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};var Xr=(e,t,i)=>{t.forEach(s=>{e.addEventListener(s,i)})},qr=(e,t,i)=>{t.forEach(s=>{e.removeEventListener(s,i)})},gs=class{constructor(t){this.defaults={idle:1e4,events:["mousemove","scroll","keydown","mousedown","touchstart"],onIdle:null,onActive:null,onHide:null,onShow:null,keepTracking:!0,startAtIdle:!1,recurIdleCall:!1},this.throwOnBadKey(Object.keys(t),Object.keys(this.defaults)),this.settings=Object.assign({},this.defaults,t),this.visibilityEvents=["visibilitychange","webkitvisibilitychange","mozvisibilitychange","msvisibilitychange"],this.clearTimeout=null,this.reset(),this.stopListener=i=>{this.stop()},this.idlenessEventsHandler=i=>{this.idle&&(this.idle=!1,this.settings.onActive&&this.settings.onActive.call()),this.resetTimeout(this.settings)},this.visibilityEventsHandler=i=>{document.hidden||document.webkitHidden||document.mozHidden||document.msHidden?this.visible&&(this.visible=!1,this.settings.onHide&&this.settings.onHide.call()):this.visible||(this.visible=!0,this.settings.onShow&&this.settings.onShow.call())}}resetTimeout(t,i=this.settings.keepTracking){this.clearTimeout&&(this.clearTimeout(),this.clearTimeout=null),i&&this.timeout(this.settings)}timeout(t){var i=this.settings.recurIdleCall?{set:setInterval.bind(window),clear:clearInterval.bind(window)}:{set:setTimeout.bind(window),clear:clearTimeout.bind(window)},s=i.set(function(){this.idle=!0,this.settings.onIdle&&this.settings.onIdle.call()}.bind(this),this.settings.idle);this.clearTimeout=()=>i.clear(s)}start(){return window.addEventListener("idle:stop",this.stopListener),this.timeout(this.settings),Xr(window,this.settings.events,this.idlenessEventsHandler),(this.settings.onShow||this.settings.onHide)&&Xr(document,this.visibilityEvents,this.visibilityEventsHandler),this}stop(){return window.removeEventListener("idle:stop",this.stopListener),qr(window,this.settings.events,this.idlenessEventsHandler),this.resetTimeout(this.settings,!1),(this.settings.onShow||this.settings.onHide)&&qr(document,this.visibilityEvents,this.visibilityEventsHandler),this}reset({idle:t=this.settings.startAtIdle,visible:i=!this.settings.startAtIdle}={}){return this.idle=t,this.visible=i,this}throwOnBadKey(t,i){t.forEach(function(s){if(!i.includes(s))throw`set: Unknown key ${s}`})}set(t){this.throwOnBadKey(Object.keys(t),Object.keys(this.defaults)),this.settings=Object.assign(this.settings,t)}};var _s=class extends Br{constructor(t,i={}){super(t,i);this.preventReconnect=!1,this.shouldReconnect=!1,this.idleMonitor=new gs({idle:3*60*1e3,onActive:this.onShowOrActive.bind(this),onShow:this.onShowOrActive.bind(this)}),this.idleMonitor.start()}isIdle(){return this.idleMonitor.idle}onShowOrActive(){if(!this.idleMonitor.visible||this.idleMonitor.idle)return;let t=!this.isConnected()&&this.connectionState()!=="connecting";t&&this.connect(),(this.shouldReconnect||t)&&(this.shouldReconnect=!1,this.reconnectTimer.scheduleTimeout())}onConnClose(t){let i=t&&t.code===1001&&t.wasClean&&t.type==="close";this.hasLogger()&&this.log("transport","close",t),this.triggerChanError(),this.clearHeartbeats(),this.preventReconnect||(!this.closeWasClean&&!i?this.scheduleReconnect():this.idleMonitor.stop()),this.stateChangeCallbacks.close.forEach(([,s])=>s(t))}scheduleReconnect(){!this.idleMonitor.idle&&this.idleMonitor.visible?this.reconnectTimer.scheduleTimeout():(this.reconnectTimer.reset(),this.shouldReconnect=!0)}};var M="search",ci="consecutive-reloads",Wr=10,Kr=5e3,zr=1e4,Jr=3e4,di=["phx-click-loading","phx-change-loading","phx-submit-loading","phx-keydown-loading","phx-keyup-loading","phx-blur-loading","phx-focus-loading","phx-hook-loading"],yt="data-phx-component";var Yr="track-static";var Bt="data-phx-ref-loading",at="data-phx-ref-src",ct="data-phx-ref-lock",ui="track-uploads",St="data-phx-upload-ref",ve="data-phx-preflighted-refs",Gr="data-phx-done-refs",vs="drop-target",Me="data-phx-active-refs",be=`${M}:live-file:updated`,fi="data-phx-skip",pi="data-phx-id",bs="data-phx-prune",ys="phx-connected",Xt="phx-loading",se="phx-error",Ss="phx-client-error",ye="phx-server-error",qt="data-phx-parent-id",mi="data-phx-main",Et="data-dfd-root-id",Ne="viewport-top",Fe="viewport-bottom",Es="trigger-action",re="phx-has-focused",Qr=["text","textarea","number","email","password","search","tel","url","date","time","datetime-local","color","range"],gi=["checkbox","radio"],ne="phx-has-submitted",gt="data-dfd-view",Ot=`[${gt}]`,ws="data-phx-sticky",Ht="data-phx-static",Ue="data-phx-readonly",Wt="data-phx-disabled",Cs="disable-with",Se="data-phx-disable-with-restore",Ee="hook",Zr="debounce",tn="throttle",oe="update",_i="stream",we="data-phx-stream",en="key",Tt="phxPrivate",As="auto-recover",$e="phx:live-socket:debug",vi="phx:live-socket:profiling",bi="phx:live-socket:latency-sim",yi="phx:nav-history-position",sn="progress",Ts="mounted",ks="__phoenix_reload_status__",rn=1,xs=3,nn=200,on="dfd-",an=3e4;var Ce="debounce-trigger",Ae="throttled",Ps="debounce-prev-key",ln={debounce:300,throttle:300},Ls=[Bt,at,ct],Ve="d",kt="s",Si="r",dt="c",Is="e",Rs="r",Os="t",hn="p",Hs="stream";var Ei=class{constructor(t,i,s){let{chunk_size:r,chunk_timeout:n}=i;this.liveSocket=s,this.entry=t,this.offset=0,this.chunkSize=r,this.chunkTimeout=n,this.chunkTimer=null,this.errored=!1,this.uploadChannel=s.channel(`lvu:${t.ref}`,{token:t.metadata()})}error(t){this.errored||(this.uploadChannel.leave(),this.errored=!0,clearTimeout(this.chunkTimer),this.entry.error(t))}upload(){this.uploadChannel.onError(t=>this.error(t)),this.uploadChannel.join().receive("ok",t=>this.readNextChunk()).receive("error",t=>this.error(t))}isDone(){return this.offset>=this.entry.file.size}readNextChunk(){let t=new window.FileReader,i=this.entry.file.slice(this.offset,this.chunkSize+this.offset);t.onload=s=>{if(s.target.error===null)this.offset+=s.target.result.byteLength,this.pushChunk(s.target.result);else return rt("Read error: "+s.target.error)},t.readAsArrayBuffer(i)}pushChunk(t){!this.uploadChannel.isJoined()||this.uploadChannel.push("chunk",t,this.chunkTimeout).receive("ok",()=>{this.entry.progress(this.offset/this.entry.file.size*100),this.isDone()||(this.chunkTimer=setTimeout(()=>this.readNextChunk(),this.liveSocket.getLatencySim()||0))}).receive("error",({reason:i})=>this.error(i))}};var rt=(e,t)=>console.error&&console.error(e,t),wt=e=>{let t=typeof e;return t==="number"||t==="string"&&/^(0|[1-9]\d*)$/.test(e)};function cn(){let e=new Set,t=document.querySelectorAll("*[id]");for(let i=0,s=t.length;i{e.liveSocket.isDebugEnabled()&&console.log(`${e.id} ${t}: ${i} - `,s)},Te=e=>typeof e=="function"?e:function(){return e},ke=e=>JSON.parse(JSON.stringify(e)),xe=(e,t,i)=>{do{if(e.matches(`[${t}]`)&&!e.disabled)return e;e=e.parentElement||e.parentNode}while(e!==null&&e.nodeType===1&&!(i&&i.isSameNode(e)||e.matches(Ot)));return null},ae=e=>e!==null&&typeof e=="object"&&!(e instanceof Array),un=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ds=e=>{for(let t in e)return!1;return!0},xt=(e,t)=>e&&t(e),fn=function(e,t,i,s){e.forEach(r=>{new Ei(r,i.config,s).upload()})};var $a={canPushState(){return typeof history.pushState!="undefined"},dropLocal(e,t,i){return e.removeItem(this.localKey(t,i))},updateLocal(e,t,i,s,r){let n=this.getLocal(e,t,i),o=this.localKey(t,i),a=n===null?s:r(n);return e.setItem(o,JSON.stringify(a)),a},getLocal(e,t,i){return JSON.parse(e.getItem(this.localKey(t,i)))},updateCurrentState(e){!this.canPushState()||history.replaceState(e(history.state||{}),"",window.location.href)},pushState(e,t,i){if(this.canPushState()){if(i!==window.location.href){if(t.type=="redirect"&&t.scroll){let s=history.state||{};s.scroll=t.scroll,history.replaceState(s,"",window.location.href)}delete t.scroll,history[e+"State"](t,"",i||null),window.requestAnimationFrame(()=>{let s=this.getHashTargetEl(window.location.hash);s?s.scrollIntoView():t.type==="redirect"&&window.scroll(0,0)})}}else this.redirect(i)},setCookie(e,t,i){let s=typeof i=="number"?` max-age=${i};`:"";document.cookie=`${e}=${t};${s} path=/`},getCookie(e){return document.cookie.replace(new RegExp(`(?:(?:^|.*;s*)${e}s*=s*([^;]*).*$)|^.*$`),"$1")},deleteCookie(e){document.cookie=`${e}=; max-age=-1; path=/`},redirect(e,t){t&&this.setCookie("__phoenix_flash__",t,60),window.location=e},localKey(e,t){return`${e}-${t}`},getHashTargetEl(e){let t=e.toString().substring(1);if(t!=="")return document.getElementById(t)||document.querySelector(`a[name="${t}"]`)}},_t=$a;var le={byId(e){return document.getElementById(e)||rt(`no id found for ${e}`)},removeClass(e,t){e.classList.remove(t),e.classList.length===0&&e.removeAttribute("class")},all(e,t,i){if(!e)return[];let s=Array.from(e.querySelectorAll(t));return i?s.forEach(i):s},childNodeLength(e){let t=document.createElement("template");return t.innerHTML=e,t.content.childElementCount},isUploadInput(e){return e.type==="file"&&e.getAttribute(St)!==null},isAutoUpload(e){return e.hasAttribute("data-phx-auto-upload")},findUploadInputs(e){let t=e.id,i=this.all(document,`input[type="file"][${St}][form="${t}"]`);return this.all(e,`input[type="file"][${St}]`).concat(i)},findComponentNodeList(e,t){return this.filterWithinSameLiveView(this.all(e,`[${yt}="${t}"]`),e)},isPhxDestroyed(e){return!!(e.id&&le.private(e,"destroyed"))},wantsNewTab(e){let t=e.ctrlKey||e.shiftKey||e.metaKey||e.button&&e.button===1,i=e.target instanceof HTMLAnchorElement&&e.target.hasAttribute("download"),s=e.target.hasAttribute("target")&&e.target.getAttribute("target").toLowerCase()==="_blank",r=e.target.hasAttribute("target")&&!e.target.getAttribute("target").startsWith("_");return t||s||i||r},isUnloadableFormSubmit(e){return e.target&&e.target.getAttribute("method")==="dialog"||e.submitter&&e.submitter.getAttribute("formmethod")==="dialog"?!1:!e.defaultPrevented&&!this.wantsNewTab(e)},isNewPageClick(e,t){let i=e.target instanceof HTMLAnchorElement?e.target.getAttribute("href"):null,s;if(e.defaultPrevented||i===null||this.wantsNewTab(e)||i.startsWith("mailto:")||i.startsWith("tel:")||e.target.isContentEditable)return!1;try{s=new URL(i)}catch(r){try{s=new URL(i,t)}catch(n){return!0}}return s.host===t.host&&s.protocol===t.protocol&&s.pathname===t.pathname&&s.search===t.search?s.hash===""&&!s.href.endsWith("#"):s.protocol.startsWith("http")},markPhxChildDestroyed(e){this.isPhxChild(e)&&e.setAttribute(gt,""),this.putPrivate(e,"destroyed",!0)},findPhxChildrenInFragment(e,t){let i=document.createElement("template");return i.innerHTML=e,this.findPhxChildren(i.content,t)},isIgnored(e,t){return(e.getAttribute(t)||e.getAttribute("data-phx-update"))==="ignore"},isPhxUpdate(e,t,i){return e.getAttribute&&i.indexOf(e.getAttribute(t))>=0},findPhxSticky(e){return this.all(e,`[${ws}]`)},findPhxChildren(e,t){return this.all(e,`${Ot}[${qt}="${t}"]`)},findExistingParentCIDs(e,t){let i=new Set,s=new Set;return t.forEach(r=>{this.filterWithinSameLiveView(this.all(e,`[${yt}="${r}"]`),e).forEach(n=>{i.add(r),this.all(n,`[${yt}]`).map(o=>parseInt(o.getAttribute(yt))).forEach(o=>s.add(o))})}),s.forEach(r=>i.delete(r)),i},filterWithinSameLiveView(e,t){return t.querySelector(Ot)?e.filter(i=>this.withinSameLiveView(i,t)):e},withinSameLiveView(e,t){for(;e=e.parentNode;){if(e.isSameNode(t))return!0;if(e.getAttribute(gt)!==null)return!1}},private(e,t){return e[Tt]&&e[Tt][t]},deletePrivate(e,t){e[Tt]&&delete e[Tt][t]},putPrivate(e,t,i){e[Tt]||(e[Tt]={}),e[Tt][t]=i},updatePrivate(e,t,i,s){let r=this.private(e,t);r===void 0?this.putPrivate(e,t,s(i)):this.putPrivate(e,t,s(r))},syncPendingAttrs(e,t){!e.hasAttribute(at)||(di.forEach(i=>{e.classList.contains(i)&&t.classList.add(i)}),Ls.filter(i=>e.hasAttribute(i)).forEach(i=>{t.setAttribute(i,e.getAttribute(i))}))},copyPrivates(e,t){t[Tt]&&(e[Tt]=t[Tt])},putTitle(e){let t=document.querySelector("title");if(t){let{prefix:i,suffix:s,default:r}=t.dataset,n=typeof e!="string"||e.trim()==="";if(n&&typeof r!="string")return;let o=n?r:e;document.title=`${i||""}${o||""}${s||""}`}else document.title=e},debounce(e,t,i,s,r,n,o,a){let l=e.getAttribute(i),h=e.getAttribute(r);l===""&&(l=s),h===""&&(h=n);let d=l||h;switch(d){case null:return a();case"blur":this.once(e,"debounce-blur")&&e.addEventListener("blur",()=>{o()&&a()});return;default:let f=parseInt(d),b=()=>h?this.deletePrivate(e,Ae):a(),v=this.incCycle(e,Ce,b);if(isNaN(f))return rt(`invalid throttle/debounce value: ${d}`);if(h){let y=!1;if(t.type==="keydown"){let C=this.private(e,Ps);this.putPrivate(e,Ps,t.key),y=C!==t.key}if(!y&&this.private(e,Ae))return!1;{a();let C=setTimeout(()=>{o()&&this.triggerCycle(e,Ce)},f);this.putPrivate(e,Ae,C)}}else setTimeout(()=>{o()&&this.triggerCycle(e,Ce,v)},f);let g=e.form;g&&this.once(g,"bind-debounce")&&g.addEventListener("submit",()=>{Array.from(new FormData(g).entries(),([y])=>{let C=g.querySelector(`[name="${y}"]`);this.incCycle(C,Ce),this.deletePrivate(C,Ae)})}),this.once(e,"bind-debounce")&&e.addEventListener("blur",()=>{clearTimeout(this.private(e,Ae)),this.triggerCycle(e,Ce)})}},triggerCycle(e,t,i){let[s,r]=this.private(e,t);i||(i=s),i===s&&(this.incCycle(e,t),r())},once(e,t){return this.private(e,t)===!0?!1:(this.putPrivate(e,t,!0),!0)},incCycle(e,t,i=function(){}){let[s]=this.private(e,t)||[0,i];return s++,this.putPrivate(e,t,[s,i]),s},maintainPrivateHooks(e,t,i,s){e.hasAttribute&&e.hasAttribute("data-phx-hook")&&!t.hasAttribute("data-phx-hook")&&t.setAttribute("data-phx-hook",e.getAttribute("data-phx-hook"))},putCustomElHook(e,t){e.isConnected?e.setAttribute("data-phx-hook",""):console.error(` hook attached to non-connected DOM element ensure you are calling createHook within your connectedCallback. ${e.outerHTML} `),this.putPrivate(e,"custom-el-hook",t)},getCustomElHook(e){return this.private(e,"custom-el-hook")},isUsedInput(e){return e.nodeType===Node.ELEMENT_NODE&&(this.private(e,re)||this.private(e,ne))},resetForm(e){Array.from(e.elements).forEach(t=>{this.deletePrivate(t,re),this.deletePrivate(t,ne)})},isPhxChild(e){return e.getAttribute&&e.getAttribute(qt)},isPhxSticky(e){return e.getAttribute&&e.getAttribute(ws)!==null},isChildOfAny(e,t){return!!t.find(i=>i.contains(e))},firstPhxChild(e){return this.isPhxChild(e)?e:this.all(e,`[${qt}]`)[0]},dispatchEvent(e,t,i={}){let s=!0;e.nodeName==="INPUT"&&e.type==="file"&&t==="click"&&(s=!1);let o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=t==="click"?new MouseEvent("click",o):new CustomEvent(t,o);e.dispatchEvent(a)},cloneNode(e,t){if(typeof t=="undefined")return e.cloneNode(!0);{let i=e.cloneNode(!1);return i.innerHTML=t,i}},mergeAttrs(e,t,i={}){let s=new Set(i.exclude||[]),r=i.isIgnored,n=t.attributes;for(let a=n.length-1;a>=0;a--){let l=n[a].name;if(s.has(l))l==="value"&&e.value===t.value&&e.setAttribute("value",t.getAttribute(l));else{let h=t.getAttribute(l);e.getAttribute(l)!==h&&(!r||r&&l.startsWith("data-"))&&e.setAttribute(l,h)}}let o=e.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;r?l.startsWith("data-")&&!t.hasAttribute(l)&&!Ls.includes(l)&&e.removeAttribute(l):t.hasAttribute(l)||e.removeAttribute(l)}},mergeFocusedInput(e,t){e instanceof HTMLSelectElement||le.mergeAttrs(e,t,{exclude:["value"]}),t.readOnly?e.setAttribute("readonly",!0):e.removeAttribute("readonly")},hasSelectionRange(e){return e.setSelectionRange&&(e.type==="text"||e.type==="textarea")},restoreFocus(e,t,i){if(e instanceof HTMLSelectElement&&e.focus(),!le.isTextualInput(e))return;e.matches(":focus")||e.focus(),this.hasSelectionRange(e)&&e.setSelectionRange(t,i)},isFormInput(e){return/^(?:input|select|textarea)$/i.test(e.tagName)&&e.type!=="button"},syncAttrsToProps(e){e instanceof HTMLInputElement&&gi.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=e.getAttribute("checked")!==null)},isTextualInput(e){return Qr.indexOf(e.type)>=0},isNowTriggerFormExternal(e,t){return e.getAttribute&&e.getAttribute(t)!==null&&document.body.contains(e)},cleanChildNodes(e,t){if(le.isPhxUpdate(e,t,["append","prepend"])){let i=[];e.childNodes.forEach(s=>{s.id||(!(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()==="")&&s.nodeType!==Node.COMMENT_NODE&&rt(`only HTML element tags with an id are allowed inside containers with phx-update. removing illegal node: "${(s.outerHTML||s.nodeValue).trim()}" `),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(e,t,i){let s=new Set(["id",gt,Ht,mi,Et]);if(e.tagName.toLowerCase()===t.toLowerCase())return Array.from(e.attributes).filter(r=>!s.has(r.name.toLowerCase())).forEach(r=>e.removeAttribute(r.name)),Object.keys(i).filter(r=>!s.has(r.toLowerCase())).forEach(r=>e.setAttribute(r,i[r])),e;{let r=document.createElement(t);return Object.keys(i).forEach(n=>r.setAttribute(n,i[n])),s.forEach(n=>r.setAttribute(n,e.getAttribute(n))),r.innerHTML=e.innerHTML,e.replaceWith(r),r}},getSticky(e,t,i){let s=(le.private(e,"sticky")||[]).find(([r])=>t===r);if(s){let[r,n,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(e,t){this.updatePrivate(e,"sticky",[],i=>i.filter(([s,r])=>s!==t))},putSticky(e,t,i){let s=i(e);this.updatePrivate(e,"sticky",[],r=>{let n=r.findIndex(([o])=>t===o);return n>=0?r[n]=[t,i,s]:r.push([t,i,s]),r})},applyStickyOperations(e){let t=le.private(e,"sticky");!t||t.forEach(([i,s,r])=>this.putSticky(e,i,s))}},p=le;var Kt=class{static isActive(t,i){let s=i._phxRef===void 0,n=t.getAttribute(Me).split(",").indexOf(W.genFileRef(i))>=0;return i.size>0&&(s||n)}static isPreflighted(t,i){return t.getAttribute(ve).split(",").indexOf(W.genFileRef(i))>=0&&this.isActive(t,i)}static isPreflightInProgress(t){return t._preflightInProgress===!0}static markPreflightInProgress(t){t._preflightInProgress=!0}constructor(t,i,s,r){this.ref=W.genFileRef(i),this.fileEl=t,this.file=i,this.view=s,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(be,this._onElUpdated),this.autoUpload=r}metadata(){return this.meta}progress(t){this._progress=Math.floor(t),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{W.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(t="failed"){this.fileEl.removeEventListener(be,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:t}),this.isAutoUpload()||W.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(t){this._onDone=()=>{this.fileEl.removeEventListener(be,this._onElUpdated),t()}}onElUpdated(){this.fileEl.getAttribute(Me).split(",").indexOf(this.ref)===-1&&(W.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(t){if(this.meta.uploader){let i=t[this.meta.uploader]||rt(`no uploader configured for ${this.meta.uploader}`);return{name:this.meta.uploader,callback:i}}else return{name:"channel",callback:fn}}zipPostFlight(t){this.meta=t.entries[this.ref],this.meta||rt(`no preflight upload response returned with ref ${this.ref}`,{input:this.fileEl,response:t})}};var Va=0,W=class{static genFileRef(t){let i=t._phxRef;return i!==void 0?i:(t._phxRef=(Va++).toString(),t._phxRef)}static getEntryDataURL(t,i,s){let r=this.activeFiles(t).find(n=>this.genFileRef(n)===i);s(URL.createObjectURL(r))}static hasUploadsInProgress(t){let i=0;return p.findUploadInputs(t).forEach(s=>{s.getAttribute(ve)!==s.getAttribute(Gr)&&i++}),i>0}static serializeUploads(t){let i=this.activeFiles(t),s={};return i.forEach(r=>{let n={path:t.name},o=t.getAttribute(St);s[o]=s[o]||[],n.ref=this.genFileRef(r),n.last_modified=r.lastModified,n.name=r.name||n.ref,n.relative_path=r.webkitRelativePath,n.type=r.type,n.size=r.size,typeof r.meta=="function"&&(n.meta=r.meta()),s[o].push(n)}),s}static clearFiles(t){t.value=null,t.removeAttribute(St),p.putPrivate(t,"files",[])}static untrackFile(t,i){p.putPrivate(t,"files",p.private(t,"files").filter(s=>!Object.is(s,i)))}static trackFiles(t,i,s){if(t.getAttribute("multiple")!==null){let r=i.filter(n=>!this.activeFiles(t).find(o=>Object.is(o,n)));p.updatePrivate(t,"files",[],n=>n.concat(r)),t.value=null}else s&&s.files.length>0&&(t.files=s.files),p.putPrivate(t,"files",i)}static activeFileInputs(t){let i=p.findUploadInputs(t);return Array.from(i).filter(s=>s.files&&this.activeFiles(s).length>0)}static activeFiles(t){return(p.private(t,"files")||[]).filter(i=>Kt.isActive(t,i))}static inputsAwaitingPreflight(t){let i=p.findUploadInputs(t);return Array.from(i).filter(s=>this.filesAwaitingPreflight(s).length>0)}static filesAwaitingPreflight(t){return this.activeFiles(t).filter(i=>!Kt.isPreflighted(t,i)&&!Kt.isPreflightInProgress(i))}static markPreflightInProgress(t){t.forEach(i=>Kt.markPreflightInProgress(i.file))}constructor(t,i,s){this.autoUpload=p.isAutoUpload(t),this.view=i,this.onComplete=s,this._entries=Array.from(W.filesAwaitingPreflight(t)||[]).map(r=>new Kt(t,r,i,this.autoUpload)),W.markPreflightInProgress(this._entries),this.numEntriesInProgress=this._entries.length}isAutoUpload(){return this.autoUpload}entries(){return this._entries}initAdapterUpload(t,i,s){this._entries=this._entries.map(n=>(n.isCancelled()?(this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()):(n.zipPostFlight(t),n.onDone(()=>{this.numEntriesInProgress--,this.numEntriesInProgress===0&&this.onComplete()})),n));let r=this._entries.reduce((n,o)=>{if(!o.meta)return n;let{name:a,callback:l}=o.uploader(s.uploaders);return n[a]=n[a]||{callback:l,entries:[]},n[a].entries.push(o),n},{});for(let n in r){let{callback:o,entries:a}=r[n];o(a,i,t,s)}}};var ja={anyOf(e,t){return t.find(i=>e instanceof i)},isFocusable(e,t){return e instanceof HTMLAnchorElement&&e.rel!=="ignore"||e instanceof HTMLAreaElement&&e.href!==void 0||!e.disabled&&this.anyOf(e,[HTMLInputElement,HTMLSelectElement,HTMLTextAreaElement,HTMLButtonElement])||e instanceof HTMLIFrameElement||e.tabIndex>0||!t&&e.getAttribute("tabindex")!==null&&e.getAttribute("aria-hidden")!=="true"},attemptFocus(e,t){if(this.isFocusable(e,t))try{e.focus()}catch(i){}return!!document.activeElement&&document.activeElement.isSameNode(e)},focusFirstInteractive(e){let t=e.firstElementChild;for(;t;){if(this.attemptFocus(t,!0)||this.focusFirstInteractive(t,!0))return!0;t=t.nextElementSibling}},focusFirst(e){let t=e.firstElementChild;for(;t;){if(this.attemptFocus(t)||this.focusFirst(t))return!0;t=t.nextElementSibling}},focusLast(e){let t=e.lastElementChild;for(;t;){if(this.attemptFocus(t)||this.focusLast(t))return!0;t=t.previousElementSibling}}},zt=ja;var Ba={LiveFileUpload:{activeRefs(){return this.el.getAttribute(Me)},preflightedRefs(){return this.el.getAttribute(ve)},mounted(){this.preflightedWas=this.preflightedRefs()},updated(){let e=this.preflightedRefs();this.preflightedWas!==e&&(this.preflightedWas=e,e===""&&this.__view().cancelSubmit(this.el.form)),this.activeRefs()===""&&(this.el.value=null),this.el.dispatchEvent(new CustomEvent(be))}},LiveImgPreview:{mounted(){this.ref=this.el.getAttribute("data-phx-entry-ref"),this.inputEl=document.getElementById(this.el.getAttribute(St)),W.getEntryDataURL(this.inputEl,this.ref,e=>{this.url=e,this.el.src=e})},destroyed(){URL.revokeObjectURL(this.url)}},FocusWrap:{mounted(){this.focusStart=this.el.firstElementChild,this.focusEnd=this.el.lastElementChild,this.focusStart.addEventListener("focus",()=>zt.focusLast(this.el)),this.focusEnd.addEventListener("focus",()=>zt.focusFirst(this.el)),this.el.addEventListener(`${M}:show-end`,()=>this.el.focus()),window.getComputedStyle(this.el).display!=="none"&&zt.focusFirst(this.el)}}},pn=Ba;var wi=class{constructor(t){this.el=t,this.loadingRef=t.hasAttribute(Bt)?parseInt(t.getAttribute(Bt),10):null,this.lockRef=t.hasAttribute(ct)?parseInt(t.getAttribute(ct),10):null}maybeUndo(t,i,s){!this.isWithin(t)||(this.undoLocks(t,i,s),this.undoLoading(t,i),this.isFullyResolvedBy(t)&&this.el.removeAttribute(at))}isWithin(t){return!(this.loadingRef!==null&&this.loadingRef>t&&this.lockRef!==null&&this.lockRef>t)}undoLocks(t,i,s){if(!this.isLockUndoneBy(t))return;let r=p.private(this.el,ct);r&&(s(r),p.deletePrivate(this.el,ct)),this.el.removeAttribute(ct);let n={detail:{ref:t,event:i},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`${M}:undo-lock:${this.lockRef}`,n))}undoLoading(t,i){if(!this.isLoadingUndoneBy(t)){this.canUndoLoading(t)&&this.el.classList.contains("phx-submit-loading")&&this.el.classList.remove("phx-change-loading");return}if(this.canUndoLoading(t)){this.el.removeAttribute(Bt);let s=this.el.getAttribute(Wt),r=this.el.getAttribute(Ue);r!==null&&(this.el.readOnly=r==="true",this.el.removeAttribute(Ue)),s!==null&&(this.el.disabled=s==="true",this.el.removeAttribute(Wt));let n=this.el.getAttribute(Se);n!==null&&(this.el.innerText=n,this.el.removeAttribute(Se));let o={detail:{ref:t,event:i},bubbles:!0,cancelable:!1};this.el.dispatchEvent(new CustomEvent(`${M}:undo-loading:${this.loadingRef}`,o))}di.forEach(s=>{(s!=="phx-submit-loading"||this.canUndoLoading(t))&&p.removeClass(this.el,s)})}isLoadingUndoneBy(t){return this.loadingRef===null?!1:this.loadingRef<=t}isLockUndoneBy(t){return this.lockRef===null?!1:this.lockRef<=t}isFullyResolvedBy(t){return(this.loadingRef===null||this.loadingRef<=t)&&(this.lockRef===null||this.lockRef<=t)}canUndoLoading(t){return this.lockRef===null||this.lockRef<=t}};var Ci=class{constructor(t,i,s){let r=new Set,n=new Set([...i.children].map(a=>a.id)),o=[];Array.from(t.children).forEach(a=>{if(a.id&&(r.add(a.id),n.has(a.id))){let l=a.previousElementSibling&&a.previousElementSibling.id;o.push({elementId:a.id,previousElementId:l})}}),this.containerId=i.id,this.updateType=s,this.elementsToModify=o,this.elementIdsToAdd=[...n].filter(a=>!r.has(a))}perform(){let t=p.byId(this.containerId);this.elementsToModify.forEach(i=>{i.previousElementId?xt(document.getElementById(i.previousElementId),s=>{xt(document.getElementById(i.elementId),r=>{r.previousElementSibling&&r.previousElementSibling.id==s.id||s.insertAdjacentElement("afterend",r)})}):xt(document.getElementById(i.elementId),s=>{s.previousElementSibling==null||t.insertAdjacentElement("afterbegin",s)})}),this.updateType=="prepend"&&this.elementIdsToAdd.reverse().forEach(i=>{xt(document.getElementById(i),s=>t.insertAdjacentElement("afterbegin",s))})}};var mn=11;function Xa(e,t){var i=t.attributes,s,r,n,o,a;if(!(t.nodeType===mn||e.nodeType===mn)){for(var l=i.length-1;l>=0;l--)s=i[l],r=s.name,n=s.namespaceURI,o=s.value,n?(r=s.localName||r,a=e.getAttributeNS(n,r),a!==o&&(s.prefix==="xmlns"&&(r=s.name),e.setAttributeNS(n,r,o))):(a=e.getAttribute(r),a!==o&&e.setAttribute(r,o));for(var h=e.attributes,d=h.length-1;d>=0;d--)s=h[d],r=s.name,n=s.namespaceURI,n?(r=s.localName||r,t.hasAttributeNS(n,r)||e.removeAttributeNS(n,r)):t.hasAttribute(r)||e.removeAttribute(r)}}var Ai,qa="http://www.w3.org/1999/xhtml",ft=typeof document=="undefined"?void 0:document,Wa=!!ft&&"content"in ft.createElement("template"),Ka=!!ft&&ft.createRange&&"createContextualFragment"in ft.createRange();function za(e){var t=ft.createElement("template");return t.innerHTML=e,t.content.childNodes[0]}function Ja(e){Ai||(Ai=ft.createRange(),Ai.selectNode(ft.body));var t=Ai.createContextualFragment(e);return t.childNodes[0]}function Ya(e){var t=ft.createElement("body");return t.innerHTML=e,t.childNodes[0]}function Ga(e){return e=e.trim(),Wa?za(e):Ka?Ja(e):Ya(e)}function Ti(e,t){var i=e.nodeName,s=t.nodeName,r,n;return i===s?!0:(r=i.charCodeAt(0),n=s.charCodeAt(0),r<=90&&n>=97?i===s.toUpperCase():n<=90&&r>=97?s===i.toUpperCase():!1)}function Qa(e,t){return!t||t===qa?ft.createElement(e):ft.createElementNS(t,e)}function Za(e,t){for(var i=e.firstChild;i;){var s=i.nextSibling;t.appendChild(i),i=s}return t}function Ms(e,t,i){e[i]!==t[i]&&(e[i]=t[i],e[i]?e.setAttribute(i,""):e.removeAttribute(i))}var gn={OPTION:function(e,t){var i=e.parentNode;if(i){var s=i.nodeName.toUpperCase();s==="OPTGROUP"&&(i=i.parentNode,s=i&&i.nodeName.toUpperCase()),s==="SELECT"&&!i.hasAttribute("multiple")&&(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),i.selectedIndex=-1)}Ms(e,t,"selected")},INPUT:function(e,t){Ms(e,t,"checked"),Ms(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var i=t.value;e.value!==i&&(e.value=i);var s=e.firstChild;if(s){var r=s.nodeValue;if(r==i||!i&&r==e.placeholder)return;s.nodeValue=i}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var i=-1,s=0,r=e.firstChild,n,o;r;)if(o=r.nodeName&&r.nodeName.toUpperCase(),o==="OPTGROUP")n=r,r=n.firstChild,r||(r=n.nextSibling,n=null);else{if(o==="OPTION"){if(r.hasAttribute("selected")){i=s;break}s++}r=r.nextSibling,!r&&n&&(r=n.nextSibling,n=null)}e.selectedIndex=i}}},je=1,_n=11,vn=3,bn=8;function Jt(){}function tl(e){if(e)return e.getAttribute&&e.getAttribute("id")||e.id}function el(e){return function(i,s,r){if(r||(r={}),typeof s=="string")if(i.nodeName==="#document"||i.nodeName==="HTML"){var n=s;s=ft.createElement("html"),s.innerHTML=n}else if(i.nodeName==="BODY"){var o=s;s=ft.createElement("html"),s.innerHTML=o;var a=s.querySelector("body");a&&(s=a)}else s=Ga(s);else s.nodeType===_n&&(s=s.firstElementChild);var l=r.getNodeKey||tl,h=r.onBeforeNodeAdded||Jt,d=r.onNodeAdded||Jt,f=r.onBeforeElUpdated||Jt,b=r.onElUpdated||Jt,v=r.onBeforeNodeDiscarded||Jt,g=r.onNodeDiscarded||Jt,y=r.onBeforeElChildrenUpdated||Jt,C=r.skipFromChildren||Jt,D=r.addChild||function(L,O){return L.appendChild(O)},R=r.childrenOnly===!0,x=Object.create(null),F=[];function B(L){F.push(L)}function U(L,O){if(L.nodeType===je)for(var Y=L.firstChild;Y;){var N=void 0;O&&(N=l(Y))?B(N):(g(Y),Y.firstChild&&U(Y,O)),Y=Y.nextSibling}}function _(L,O,Y){v(L)!==!1&&(O&&O.removeChild(L),g(L),U(L,Y))}function T(L){if(L.nodeType===je||L.nodeType===_n)for(var O=L.firstChild;O;){var Y=l(O);Y&&(x[Y]=O),T(O),O=O.nextSibling}}T(i);function et(L){d(L);for(var O=L.firstChild;O;){var Y=O.nextSibling,N=l(O);if(N){var $=x[N];$&&Ti(O,$)?(O.parentNode.replaceChild($,O),K($,O)):et(O)}else et(O);O=Y}}function it(L,O,Y){for(;O;){var N=O.nextSibling;(Y=l(O))?B(Y):_(O,L,!0),O=N}}function K(L,O,Y){var N=l(O);if(N&&delete x[N],!Y){var $=f(L,O);if($===!1||($ instanceof HTMLElement&&(L=$,T(L)),e(L,O),b(L),y(L,O)===!1))return}L.nodeName!=="TEXTAREA"?mt(L,O):gn.TEXTAREA(L,O)}function mt(L,O){var Y=C(L,O),N=O.firstChild,$=L.firstChild,jt,vt,It,te,lt;t:for(;N;){for(te=N.nextSibling,jt=l(N);!Y&&$;){if(It=$.nextSibling,N.isSameNode&&N.isSameNode($)){N=te,$=It;continue t}vt=l($);var _e=$.nodeType,Ct=void 0;if(_e===N.nodeType&&(_e===je?(jt?jt!==vt&&((lt=x[jt])?It===lt?Ct=!1:(L.insertBefore(lt,$),vt?B(vt):_($,L,!0),$=lt,vt=l($)):Ct=!1):vt&&(Ct=!1),Ct=Ct!==!1&&Ti($,N),Ct&&K($,N)):(_e===vn||_e==bn)&&(Ct=!0,$.nodeValue!==N.nodeValue&&($.nodeValue=N.nodeValue))),Ct){N=te,$=It;continue t}vt?B(vt):_($,L,!0),$=It}if(jt&&(lt=x[jt])&&Ti(lt,N))Y||D(L,lt),K(lt,N);else{var Le=h(N);Le!==!1&&(Le&&(N=Le),N.actualize&&(N=N.actualize(L.ownerDocument||ft)),D(L,N),et(N))}N=te,$=It}it(L,$,vt);var ii=gn[L.nodeName];ii&&ii(L,O)}var z=i,Dt=z.nodeType,Mt=s.nodeType;if(!R){if(Dt===je)Mt===je?Ti(i,s)||(g(i),z=Za(i,Qa(s.nodeName,s.namespaceURI))):z=s;else if(Dt===vn||Dt===bn){if(Mt===Dt)return z.nodeValue!==s.nodeValue&&(z.nodeValue=s.nodeValue),z;z=s}}if(z===s)g(i);else{if(s.isSameNode&&s.isSameNode(z))return;if(K(z,s,R),F)for(var Vt=0,Zt=F.length;Vt{if(p.syncPendingAttrs(h,d),!t.isSameNode(h)&&h.hasAttribute(ct)||p.isIgnored(h,a))return!1;if(r&&r.isSameNode(h)&&p.isFormInput(h))return p.mergeFocusedInput(h,d),!1;p.isNowTriggerFormExternal(d,s.binding(Es))&&(l=d)}}),l&&(s.unload(),Object.getPrototypeOf(l).submit.call(l)),s.silenceEvents(()=>p.restoreFocus(r,n,o))}constructor(t,i,s,r,n,o){this.view=t,this.liveSocket=t.liveSocket,this.container=i,this.id=s,this.rootID=t.root.id,this.html=r,this.streams=n,this.streamInserts={},this.streamComponentRestore={},this.targetCID=o,this.cidPatch=wt(this.targetCID),this.pendingRemoves=[],this.phxRemove=this.liveSocket.binding("remove"),this.targetContainer=this.isCIDPatch()?this.targetCIDContainer(r):i,this.callbacks={beforeadded:[],beforeupdated:[],beforephxChildAdded:[],afteradded:[],afterupdated:[],afterdiscarded:[],afterphxChildAdded:[],aftertransitionsDiscarded:[]}}before(t,i){this.callbacks[`before${t}`].push(i)}after(t,i){this.callbacks[`after${t}`].push(i)}trackBefore(t,...i){this.callbacks[`before${t}`].forEach(s=>s(...i))}trackAfter(t,...i){this.callbacks[`after${t}`].forEach(s=>s(...i))}markPrunableContentForRemoval(){let t=this.liveSocket.binding(oe);p.all(this.container,`[${t}=append] > *, [${t}=prepend] > *`,i=>{i.setAttribute(bs,"")})}perform(t){let{view:i,liveSocket:s,html:r,container:n,targetContainer:o}=this;if(this.isCIDPatch()&&!o)return;let a=s.getActiveElement(),{selectionStart:l,selectionEnd:h}=a&&p.hasSelectionRange(a)?a:{},d=s.binding(oe),f=s.binding(Ne),b=s.binding(Fe),v=s.binding(Es),g=[],y=[],C=[],D=null;function R(x,F,B=!1){let U={childrenOnly:x.getAttribute(yt)===null&&!B,getNodeKey:_=>p.isPhxDestroyed(_)?null:t?_.id:_.id||_.getAttribute&&_.getAttribute(pi),skipFromChildren:_=>_.getAttribute(d)===_i,addChild:(_,T)=>{let{ref:et,streamAt:it}=this.getStreamInsert(T);if(et===void 0)return _.appendChild(T);if(this.setStreamRef(T,et),it===0)_.insertAdjacentElement("afterbegin",T);else if(it===-1){let K=_.lastElementChild;if(K&&!K.hasAttribute(we)){let mt=Array.from(_.children).find(z=>!z.hasAttribute(we));_.insertBefore(T,mt)}else _.appendChild(T)}else if(it>0){let K=Array.from(_.children)[it];_.insertBefore(T,K)}},onBeforeNodeAdded:_=>{p.maintainPrivateHooks(_,_,f,b),this.trackBefore("added",_);let T=_;return this.streamComponentRestore[_.id]&&(T=this.streamComponentRestore[_.id],delete this.streamComponentRestore[_.id],R.call(this,T,_,!0)),T},onNodeAdded:_=>{_.getAttribute&&this.maybeReOrderStream(_,!0),_ instanceof HTMLImageElement&&_.srcset?_.srcset=_.srcset:_ instanceof HTMLVideoElement&&_.autoplay&&_.play(),p.isNowTriggerFormExternal(_,v)&&(D=_),(p.isPhxChild(_)&&i.ownsElement(_)||p.isPhxSticky(_)&&i.ownsElement(_.parentNode))&&this.trackAfter("phxChildAdded",_),g.push(_)},onNodeDiscarded:_=>this.onNodeDiscarded(_),onBeforeNodeDiscarded:_=>_.getAttribute&&_.getAttribute(bs)!==null?!0:!(_.parentElement!==null&&_.id&&p.isPhxUpdate(_.parentElement,d,[_i,"append","prepend"])||this.maybePendingRemove(_)||this.skipCIDSibling(_)),onElUpdated:_=>{p.isNowTriggerFormExternal(_,v)&&(D=_),y.push(_),this.maybeReOrderStream(_,!1)},onBeforeElUpdated:(_,T)=>{if(_.id&&_.isSameNode(x)&&_.id!==T.id)return U.onNodeDiscarded(_),_.replaceWith(T),U.onNodeAdded(T);if(p.syncPendingAttrs(_,T),p.maintainPrivateHooks(_,T,f,b),p.cleanChildNodes(T,d),this.skipCIDSibling(T))return this.maybeReOrderStream(_),!1;if(p.isPhxSticky(_))return[gt,Ht,Et].map(K=>[K,_.getAttribute(K),T.getAttribute(K)]).forEach(([K,mt,z])=>{z&&mt!==z&&_.setAttribute(K,z)}),!1;if(p.isIgnored(_,d)||_.form&&_.form.isSameNode(D))return this.trackBefore("updated",_,T),p.mergeAttrs(_,T,{isIgnored:p.isIgnored(_,d)}),y.push(_),p.applyStickyOperations(_),!1;if(_.type==="number"&&_.validity&&_.validity.badInput)return!1;let et=a&&_.isSameNode(a)&&p.isFormInput(_),it=et&&this.isChangedSelect(_,T);if(_.hasAttribute(at)){p.isUploadInput(_)&&(p.mergeAttrs(_,T,{isIgnored:!0}),this.trackBefore("updated",_,T),y.push(_)),p.applyStickyOperations(_);let mt=_.hasAttribute(ct)?p.private(_,ct)||_.cloneNode(!0):null;mt&&(p.putPrivate(_,ct,mt),et||(_=mt))}if(p.isPhxChild(T)){let K=_.getAttribute(gt);return p.mergeAttrs(_,T,{exclude:[Ht]}),K!==""&&_.setAttribute(gt,K),_.setAttribute(Et,this.rootID),p.applyStickyOperations(_),!1}return p.copyPrivates(T,_),et&&_.type!=="hidden"&&!it?(this.trackBefore("updated",_,T),p.mergeFocusedInput(_,T),p.syncAttrsToProps(_),y.push(_),p.applyStickyOperations(_),!1):(it&&_.blur(),p.isPhxUpdate(T,d,["append","prepend"])&&C.push(new Ci(_,T,T.getAttribute(d))),p.syncAttrsToProps(T),p.applyStickyOperations(T),this.trackBefore("updated",_,T),_)}};Ns(x,F,U)}return this.trackBefore("added",n),this.trackBefore("updated",n,n),s.time("morphdom",()=>{this.streams.forEach(([x,F,B,U])=>{F.forEach(([_,T,et])=>{this.streamInserts[_]={ref:x,streamAt:T,limit:et,reset:U}}),U!==void 0&&p.all(n,`[${we}="${x}"]`,_=>{this.removeStreamChildElement(_)}),B.forEach(_=>{let T=n.querySelector(`[id="${_}"]`);T&&this.removeStreamChildElement(T)})}),t&&p.all(this.container,`[${d}=${_i}]`,x=>{this.liveSocket.owner(x,F=>{F===this.view&&Array.from(x.children).forEach(B=>{this.removeStreamChildElement(B)})})}),R.call(this,o,r)}),s.isDebugEnabled()&&(cn(s.doofinderMount),Array.from(document.querySelectorAll("input[name=id]")).forEach(x=>{x.form&&console.error(`Detected an input with name="id" inside a form! This will cause problems when patching the DOM. `,x)})),C.length>0&&s.time("post-morph append/prepend restoration",()=>{C.forEach(x=>x.perform())}),s.silenceEvents(()=>p.restoreFocus(a,l,h)),p.dispatchEvent(document,`${M}:update`),g.forEach(x=>this.trackAfter("added",x)),y.forEach(x=>this.trackAfter("updated",x)),this.transitionPendingRemoves(),D&&(s.unload(),Object.getPrototypeOf(D).submit.call(D)),!0}onNodeDiscarded(t){(p.isPhxChild(t)||p.isPhxSticky(t))&&this.liveSocket.destroyViewByEl(t),this.trackAfter("discarded",t)}maybePendingRemove(t){return t.getAttribute&&t.getAttribute(this.phxRemove)!==null?(this.pendingRemoves.push(t),!0):!1}removeStreamChildElement(t){this.streamInserts[t.id]?(this.streamComponentRestore[t.id]=t,t.remove()):this.maybePendingRemove(t)||(t.remove(),this.onNodeDiscarded(t))}getStreamInsert(t){return(t.id?this.streamInserts[t.id]:{})||{}}setStreamRef(t,i){p.putSticky(t,we,s=>s.setAttribute(we,i))}maybeReOrderStream(t,i){let{ref:s,streamAt:r,reset:n}=this.getStreamInsert(t);if(r!==void 0&&(this.setStreamRef(t,s),!(!n&&!i)&&!!t.parentElement)){if(r===0)t.parentElement.insertBefore(t,t.parentElement.firstElementChild);else if(r>0){let o=Array.from(t.parentElement.children),a=o.indexOf(t);if(r>=o.length-1)t.parentElement.appendChild(t);else{let l=o[r];a>r?t.parentElement.insertBefore(t,l):t.parentElement.insertBefore(t,l.nextElementSibling)}}this.maybeLimitStream(t)}}maybeLimitStream(t){let{limit:i}=this.getStreamInsert(t),s=i!==null&&Array.from(t.parentElement.children);i&&i<0&&s.length>i*-1?s.slice(0,s.length+i).forEach(r=>this.removeStreamChildElement(r)):i&&i>=0&&s.length>i&&s.slice(i).forEach(r=>this.removeStreamChildElement(r))}transitionPendingRemoves(){let{pendingRemoves:t,liveSocket:i}=this;t.length>0&&i.transitionRemoves(t,!1,()=>{t.forEach(s=>{let r=p.firstPhxChild(s);r&&i.destroyViewByEl(r),s.remove()}),this.trackAfter("transitionsDiscarded",t)})}isChangedSelect(t,i){return!(t instanceof HTMLSelectElement)||t.multiple?!1:t.options.length!==i.options.length?!0:(i.value=t.value,!t.isEqualNode(i))}isCIDPatch(){return this.cidPatch}skipCIDSibling(t){return t.nodeType===Node.ELEMENT_NODE&&t.hasAttribute(fi)}targetCIDContainer(t){if(!this.isCIDPatch())return;let[i,...s]=p.findComponentNodeList(this.container,this.targetCID);return s.length===0&&p.childNodeLength(t)===1?i:i&&i.parentNode}indexOf(t,i){return Array.from(t.children).indexOf(i)}};var sl=new Set(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),rl=new Set(["'",'"']),yn=(e,t,i)=>{let s=0,r=!1,n,o,a,l,h,d,f=e.match(/^(\s*(?:\s*)*)<([^\s\/>]+)/);if(f===null)throw new Error(`malformed html ${e}`);for(s=f[0].length,n=f[1],a=f[2],l=s,s;s";s++)if(e.charAt(s)==="="){let g=e.slice(s-3,s)===" id";s++;let y=e.charAt(s);if(rl.has(y)){let C=s;for(s++,s;s=n.length+a.length;){let g=e.charAt(b);if(r)g==="-"&&e.slice(b-3,b)===""&&e.slice(b-2,b)==="--")r=!0,b-=3;else{if(g===">")break;b-=1}}o=e.slice(b+1,e.length);let v=Object.keys(t).map(g=>t[g]===!0?g:`${g}="${t[g]}"`).join(" ");if(i){let g=h?` id="${h}"`:"";sl.has(a)?d=`<${a}${g}${v===""?"":" "}${v}/>`:d=`<${a}${g}${v===""?"":" "}${v}>`}else{let g=e.slice(l,b+1);d=`<${a}${v===""?"":" "}${v}${g}`}return[d,n,o]},Be=class{static extract(t){let{[Rs]:i,[Is]:s,[Os]:r}=t;return delete t[Rs],delete t[Is],delete t[Os],{diff:t,title:r,reply:i||null,events:s||[]}}constructor(t,i){this.viewId=t,this.rendered={},this.magicId=0,this.mergeDiff(i)}parentViewId(){return this.viewId}toString(t){let[i,s]=this.recursiveToString(this.rendered,this.rendered[dt],t,!0,{});return[i,s]}recursiveToString(t,i=t[dt],s,r,n){s=s?new Set(s):null;let o={buffer:"",components:i,onlyCids:s,streams:new Set};return this.toOutputBuffer(t,null,o,r,n),[o.buffer,o.streams]}componentCIDs(t){return Object.keys(t[dt]||{}).map(i=>parseInt(i))}isComponentOnlyDiff(t){return t[dt]?Object.keys(t).length===1:!1}getComponent(t,i){return t[dt][i]}resetRender(t){this.rendered[dt][t]&&(this.rendered[dt][t].reset=!0)}mergeDiff(t){let i=t[dt],s={};if(delete t[dt],this.rendered=this.mutableMerge(this.rendered,t),this.rendered[dt]=this.rendered[dt]||{},i){let r=this.rendered[dt];for(let n in i)i[n]=this.cachedFindComponent(n,i[n],r,i,s);for(let n in i)r[n]=i[n];t[dt]=i}}cachedFindComponent(t,i,s,r,n){if(n[t])return n[t];{let o,a,l=i[kt];if(wt(l)){let h;l>0?h=this.cachedFindComponent(l,r[l],s,r,n):h=s[-l],a=h[kt],o=this.cloneMerge(h,i,!0),o[kt]=a}else o=i[kt]!==void 0||s[t]===void 0?i:this.cloneMerge(s[t],i,!1);return n[t]=o,o}}mutableMerge(t,i){return i[kt]!==void 0?i:(this.doMutableMerge(t,i),t)}doMutableMerge(t,i){for(let s in i){let r=i[s],n=t[s];ae(r)&&r[kt]===void 0&&ae(n)?this.doMutableMerge(n,r):t[s]=r}t[Si]&&(t.newRender=!0)}cloneMerge(t,i,s){let r=P(P({},t),i);for(let n in r){let o=i[n],a=t[n];ae(o)&&o[kt]===void 0&&ae(a)?r[n]=this.cloneMerge(a,o,s):o===void 0&&ae(a)&&(r[n]=this.cloneMerge(a,{},s))}return s?(delete r.magicId,delete r.newRender):t[Si]&&(r.newRender=!0),r}componentToString(t){let[i,s]=this.recursiveCIDToString(this.rendered[dt],t,null),[r,n,o]=yn(i,{});return[r,s]}pruneCIDs(t){t.forEach(i=>delete this.rendered[dt][i])}get(){return this.rendered}isNewFingerprint(t={}){return!!t[kt]}templateStatic(t,i){return typeof t=="number"?i[t]:t}nextMagicID(){return this.magicId++,`m${this.magicId}-${this.parentViewId()}`}toOutputBuffer(t,i,s,r,n={}){if(t[Ve])return this.comprehensionToBuffer(t,i,s);let{[kt]:o}=t;o=this.templateStatic(o,i);let a=t[Si],l=s.buffer;a&&(s.buffer=""),r&&a&&!t.magicId&&(t.newRender=!0,t.magicId=this.nextMagicID()),s.buffer+=o[0];for(let h=1;h0||h.length>0||d)&&(delete t[Hs],t[Ve]=[],s.streams.add(o))}dynamicToBuffer(t,i,s,r){if(typeof t=="number"){let[n,o]=this.recursiveCIDToString(s.components,t,s.onlyCids);s.buffer+=n,s.streams=new Set([...s.streams,...o])}else ae(t)?this.toOutputBuffer(t,i,s,r,{}):s.buffer+=t}recursiveCIDToString(t,i,s){let r=t[i]||rt(`no component for CID ${i}`,t),n={[yt]:i},o=s&&!s.has(i);r.newRender=!o,r.magicId=`c${i}-${this.parentViewId()}`;let a=!r.reset,[l,h]=this.recursiveToString(r,t,s,a,n);return delete r.reset,[l,h]}};var Sn=[],En=200,nl={exec(e,t,i,s,r,n){let[o,a]=n||[null,{callback:n&&n.callback}];(i.charAt(0)==="["?JSON.parse(i):[[o,a]]).forEach(([h,d])=>{h===o&&(d=P(P({},a),d),d.callback=d.callback||a.callback),this.filterToEls(s.liveSocket,r,d).forEach(f=>{this[`exec_${h}`](e,t,i,s,r,f,d)})})},isVisible(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length>0)},isInViewport(e){let t=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth;return t.right>0&&t.bottom>0&&t.left{let d=h.getAttribute(o);if(!d)throw new Error(`expected ${o} to contain JS command on "${a}"`);s.liveSocket.execJS(h,d,t)})},exec_dispatch(e,t,i,s,r,n,{event:o,detail:a,bubbles:l}){a=a||{},a.dispatcher=r,p.dispatchEvent(n,o,{detail:a,bubbles:l})},exec_push(e,t,i,s,r,n,o){let{event:a,data:l,target:h,page_loading:d,loading:f,value:b,dispatcher:v,callback:g}=o,y={loading:f,value:b,target:h,page_loading:!!d},C=t==="change"&&v?v:r,D=h||C.getAttribute(s.binding("target"))||C,R=(x,F)=>{if(!!x.isConnected())if(t==="change"){let{newCid:B,_target:U}=o;U=U||(p.isFormInput(r)?r.name:void 0),U&&(y._target=U),x.pushInput(r,F,B,a||i,y,g)}else if(t==="submit"){let{submitter:B}=o;x.submitForm(r,F,a||i,B,y,g)}else x.pushEvent(t,r,F,a||i,l,y,g)};o.targetView&&o.targetCtx?R(o.targetView,o.targetCtx):s.withinTargets(D,R)},exec_navigate(e,t,i,s,r,n,{href:o,replace:a}){s.liveSocket.historyRedirect(e,o,a?"replace":"push",null,r)},exec_patch(e,t,i,s,r,n,{href:o,replace:a}){s.liveSocket.pushHistoryPatch(e,o,a?"replace":"push",r)},exec_focus(e,t,i,s,r,n){window.requestAnimationFrame(()=>zt.attemptFocus(n))},exec_focus_first(e,t,i,s,r,n){window.requestAnimationFrame(()=>zt.focusFirstInteractive(n)||zt.focusFirst(n))},exec_push_focus(e,t,i,s,r,n){window.requestAnimationFrame(()=>Sn.push(n||r))},exec_pop_focus(e,t,i,s,r,n){window.requestAnimationFrame(()=>{let o=Sn.pop();o&&o.focus()})},exec_add_class(e,t,i,s,r,n,{names:o,transition:a,time:l,blocking:h}){this.addOrRemoveClasses(n,o,[],a,l,s,h)},exec_remove_class(e,t,i,s,r,n,{names:o,transition:a,time:l,blocking:h}){this.addOrRemoveClasses(n,[],o,a,l,s,h)},exec_toggle_class(e,t,i,s,r,n,{names:o,transition:a,time:l,blocking:h}){this.toggleClasses(n,o,a,l,s,h)},exec_toggle_attr(e,t,i,s,r,n,{attr:[o,a,l]}){this.toggleAttr(n,o,a,l)},exec_transition(e,t,i,s,r,n,{time:o,transition:a,blocking:l}){this.addOrRemoveClasses(n,[],[],a,o,s,l)},exec_toggle(e,t,i,s,r,n,{display:o,ins:a,outs:l,time:h,blocking:d}){this.toggle(t,s,n,o,a,l,h,d)},exec_show(e,t,i,s,r,n,{display:o,transition:a,time:l,blocking:h}){this.show(t,s,n,o,a,l,h)},exec_hide(e,t,i,s,r,n,{display:o,transition:a,time:l,blocking:h}){this.hide(t,s,n,o,a,l,h)},exec_set_attr(e,t,i,s,r,n,{attr:[o,a]}){this.setOrRemoveAttrs(n,[[o,a]],[])},exec_remove_attr(e,t,i,s,r,n,{attr:o}){this.setOrRemoveAttrs(n,[],[o])},show(e,t,i,s,r,n,o){this.isVisible(i)||this.toggle(e,t,i,s,r,null,n,o)},hide(e,t,i,s,r,n,o){this.isVisible(i)&&this.toggle(e,t,i,s,null,r,n,o)},toggle(e,t,i,s,r,n,o,a){o=o||En;let[l,h,d]=r||[[],[],[]],[f,b,v]=n||[[],[],[]];if(l.length>0||f.length>0)if(this.isVisible(i)){let g=()=>{this.addOrRemoveClasses(i,b,l.concat(h).concat(d)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,f,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,v,b))})},y=()=>{this.addOrRemoveClasses(i,[],f.concat(v)),p.putSticky(i,"toggle",C=>C.style.display="none"),i.dispatchEvent(new Event(`${M}:hide-end`))};i.dispatchEvent(new Event(`${M}:hide-start`)),a===!1?(g(),setTimeout(y,o)):t.transition(o,g,y)}else{if(e==="remove")return;let g=()=>{this.addOrRemoveClasses(i,h,f.concat(b).concat(v));let C=s||this.defaultDisplay(i);p.putSticky(i,"toggle",D=>D.style.display=C),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(i,l,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(i,d,h))})},y=()=>{this.addOrRemoveClasses(i,[],l.concat(d)),i.dispatchEvent(new Event(`${M}:show-end`))};i.dispatchEvent(new Event(`${M}:show-start`)),a===!1?(g(),setTimeout(y,o)):t.transition(o,g,y)}else this.isVisible(i)?window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${M}:hide-start`)),p.putSticky(i,"toggle",g=>g.style.display="none"),i.dispatchEvent(new Event(`${M}:hide-end`))}):window.requestAnimationFrame(()=>{i.dispatchEvent(new Event(`${M}:show-start`));let g=s||this.defaultDisplay(i);p.putSticky(i,"toggle",y=>y.style.display=g),i.dispatchEvent(new Event(`${M}:show-end`))})},toggleClasses(e,t,i,s,r,n){window.requestAnimationFrame(()=>{let[o,a]=p.getSticky(e,"classes",[[],[]]),l=t.filter(d=>o.indexOf(d)<0&&!e.classList.contains(d)),h=t.filter(d=>a.indexOf(d)<0&&e.classList.contains(d));this.addOrRemoveClasses(e,l,h,i,s,r,n)})},toggleAttr(e,t,i,s){e.hasAttribute(t)?s!==void 0?e.getAttribute(t)===i?this.setOrRemoveAttrs(e,[[t,s]],[]):this.setOrRemoveAttrs(e,[[t,i]],[]):this.setOrRemoveAttrs(e,[],[t]):this.setOrRemoveAttrs(e,[[t,i]],[])},addOrRemoveClasses(e,t,i,s,r,n,o){r=r||En;let[a,l,h]=s||[[],[],[]];if(a.length>0){let d=()=>{this.addOrRemoveClasses(e,l,[].concat(a).concat(h)),window.requestAnimationFrame(()=>{this.addOrRemoveClasses(e,a,[]),window.requestAnimationFrame(()=>this.addOrRemoveClasses(e,h,l))})},f=()=>this.addOrRemoveClasses(e,t.concat(h),i.concat(a).concat(l));o===!1?(d(),setTimeout(f,r)):n.transition(r,d,f);return}window.requestAnimationFrame(()=>{let[d,f]=p.getSticky(e,"classes",[[],[]]),b=t.filter(C=>d.indexOf(C)<0&&!e.classList.contains(C)),v=i.filter(C=>f.indexOf(C)<0&&e.classList.contains(C)),g=d.filter(C=>i.indexOf(C)<0).concat(b),y=f.filter(C=>t.indexOf(C)<0).concat(v);p.putSticky(e,"classes",C=>(C.classList.remove(...y),C.classList.add(...g),[g,y]))})},setOrRemoveAttrs(e,t,i){let[s,r]=p.getSticky(e,"attrs",[[],[]]),n=t.map(([l,h])=>l).concat(i),o=s.filter(([l,h])=>!n.includes(l)).concat(t),a=r.filter(l=>!n.includes(l)).concat(i);p.putSticky(e,"attrs",l=>(a.forEach(h=>l.removeAttribute(h)),o.forEach(([h,d])=>l.setAttribute(h,d)),[o,a]))},hasAllClasses(e,t){return t.every(i=>e.classList.contains(i))},isToggledOut(e,t){return!this.isVisible(e)||this.hasAllClasses(e,t)},filterToEls(e,t,{to:i}){let s=()=>{if(typeof i=="string")return document.querySelectorAll(i);if(i.closest){let r=t.closest(i.closest);return r?[r]:[]}else if(i.inner)return t.querySelectorAll(i.inner)};return i?e.jsQuerySelectorAll(t,i,s):[t]},defaultDisplay(e){return{tr:"table-row",td:"table-cell"}[e.tagName.toLowerCase()]||"block"},transitionClasses(e){if(!e)return null;let[t,i,s]=Array.isArray(e)?e:[e.split(" "),[],[]];return t=Array.isArray(t)?t:t.split(" "),i=Array.isArray(i)?i:i.split(" "),s=Array.isArray(s)?s:s.split(" "),[t,i,s]}},j=nl;var Fs="hookId",ol=1,Ft=class{static makeID(){return ol++}static elementID(t){return p.private(t,Fs)}constructor(t,i,s){this.el=i,this.__attachView(t),this.__callbacks=s,this.__listeners=new Set,this.__isDisconnected=!1,p.putPrivate(this.el,Fs,this.constructor.makeID());for(let r in this.__callbacks)this[r]=this.__callbacks[r]}__attachView(t){t?(this.__view=()=>t,this.liveSocket=t.liveSocket):(this.__view=()=>{throw new Error(`hook not yet attached to a live view: ${this.el.outerHTML}`)},this.liveSocket=null)}__mounted(){this.mounted&&this.mounted()}__updated(){this.updated&&this.updated()}__beforeUpdate(){this.beforeUpdate&&this.beforeUpdate()}__destroyed(){this.destroyed&&this.destroyed(),p.deletePrivate(this.el,Fs)}__reconnected(){this.__isDisconnected&&(this.__isDisconnected=!1,this.reconnected&&this.reconnected())}__disconnected(){this.__isDisconnected=!0,this.disconnected&&this.disconnected()}js(){let t=this;return{exec(i){t.__view().liveSocket.execJS(t.el,i,"hook")},show(i,s={}){let r=t.__view().liveSocket.owner(i);j.show("hook",r,i,s.display,s.transition,s.time,s.blocking)},hide(i,s={}){let r=t.__view().liveSocket.owner(i);j.hide("hook",r,i,null,s.transition,s.time,s.blocking)},toggle(i,s={}){let r=t.__view().liveSocket.owner(i);s.in=j.transitionClasses(s.in),s.out=j.transitionClasses(s.out),j.toggle("hook",r,i,s.display,s.in,s.out,s.time,s.blocking)},addClass(i,s,r={}){s=Array.isArray(s)?s:s.split(" ");let n=t.__view().liveSocket.owner(i);j.addOrRemoveClasses(i,s,[],r.transition,r.time,n,r.blocking)},removeClass(i,s,r={}){r.transition=j.transitionClasses(r.transition),s=Array.isArray(s)?s:s.split(" ");let n=t.__view().liveSocket.owner(i);j.addOrRemoveClasses(i,[],s,r.transition,r.time,n,r.blocking)},toggleClass(i,s,r={}){r.transition=j.transitionClasses(r.transition),s=Array.isArray(s)?s:s.split(" ");let n=t.__view().liveSocket.owner(i);j.toggleClasses(i,s,r.transition,r.time,n,r.blocking)},transition(i,s,r={}){let n=t.__view().liveSocket.owner(i);j.addOrRemoveClasses(i,[],[],j.transitionClasses(s),r.time,n,r.blocking)},setAttribute(i,s,r){j.setOrRemoveAttrs(i,[[s,r]],[])},removeAttribute(i,s){j.setOrRemoveAttrs(i,[],[s])},toggleAttribute(i,s,r,n){j.toggleAttr(i,s,r,n)}}}pushEvent(t,i={},s){return s===void 0?new Promise((r,n)=>{try{this.__view().pushHookEvent(this.el,null,t,i,(a,l)=>r(a))===!1&&n(new Error("unable to push hook event. LiveView not connected"))}catch(o){n(o)}}):this.__view().pushHookEvent(this.el,null,t,i,s)}pushEventTo(t,i,s={},r){return r===void 0?new Promise((n,o)=>{try{this.__view().withinTargets(t,(a,l)=>{a.pushHookEvent(this.el,l,i,s,(d,f)=>n(d))===!1&&o(new Error("unable to push hook event. LiveView not connected"))})}catch(a){o(a)}}):this.__view().withinTargets(t,(n,o)=>n.pushHookEvent(this.el,o,i,s,r))}handleEvent(t,i){let s=(r,n)=>n?t:i(r.detail);return this.liveSocket.doofinderMount.addEventListener(`${M}:${t}`,s),this.__listeners.add(s),s}removeHandleEvent(t){let i=t(null,!0);this.liveSocket.doofinderMount.removeEventListener(`${M}:${i}`,t),this.__listeners.delete(t)}upload(t,i){return this.__view().dispatchUploads(null,t,i)}uploadTo(t,i,s){return this.__view().withinTargets(t,(r,n)=>{r.dispatchUploads(n,i,s)})}__cleanup__(){this.__listeners.forEach(t=>this.removeHandleEvent(t))}};var al=(e,t)=>{let i=e.endsWith("[]"),s=i?e.slice(0,-2):e;return s=s.replace(/([^\[\]]+)(\]?$)/,`${t}$1$2`),i&&(s+="[]"),s},ki=(e,t,i=[])=>{let d=t,{submitter:s}=d,r=Ur(d,["submitter"]),n;if(s&&s.name){let f=document.createElement("input");f.type="hidden";let b=s.getAttribute("form");b&&f.setAttribute("form",b),f.name=s.name,f.value=s.value,s.parentElement.insertBefore(f,s),n=f}let o=new FormData(e),a=[];o.forEach((f,b,v)=>{f instanceof File&&a.push(b)}),a.forEach(f=>o.delete(f));let l=new URLSearchParams,h=Array.from(e.elements);for(let[f,b]of o.entries())if(i.length===0||i.indexOf(f)>=0){let v=h.filter(C=>C.name===f),g=!v.some(C=>p.private(C,re)||p.private(C,ne)),y=v.every(C=>C.type==="hidden");g&&!(s&&s.name==f)&&!y&&l.append(al(f,"_unused_"),""),l.append(f,b)}s&&n&&s.parentElement.removeChild(n);for(let f in r)l.append(f,r[f]);return l.toString()},ce=class{static closestView(t){let i=t.closest(Ot);return i?p.private(i,"view"):null}constructor(t,i,s,r,n){this.isDead=!1,this.liveSocket=i,this.flash=r,this.parent=s,this.root=s?s.root:this,this.el=t,p.putPrivate(this.el,"view",this),this.id=this.el.id,this.ref=0,this.lastAckRef=null,this.childJoins=0,this.loaderTimer=null,this.pendingDiffs=[],this.pendingForms=new Set,this.redirect=!1,this.href=null,this.joinCount=this.parent?this.parent.joinCount-1:0,this.joinAttempts=0,this.joinPending=!0,this.destroyed=!1,this.joinCallback=function(o){o&&o()},this.stopCallback=function(){},this.pendingJoinOps=this.parent?null:[],this.viewHooks={},this.formSubmits=[],this.children=this.parent?null:{},this.root.children[this.id]={},this.formsForRecovery={},this.channel=this.liveSocket.channel(`lv:${this.id}`,()=>{let o=this.href&&this.expandURL(this.href);return{redirect:this.redirect?o:void 0,url:this.redirect?void 0:o||void 0,params:this.connectParams(n),session:this.getSession(),static:this.getStatic(),flash:this.flash}})}setHref(t){this.href=t}setRedirect(t){this.redirect=!0,this.href=t}isMain(){return this.el.hasAttribute(mi)}connectParams(t){let i=this.liveSocket.params(this.el),s=p.all(document,`[${this.binding(Yr)}]`).map(r=>r.src||r.href).filter(r=>typeof r=="string");return s.length>0&&(i._track_static=s),i._mounts=this.joinCount,i._mount_attempts=this.joinAttempts,i._live_referer=t,this.joinAttempts++,i}isConnected(){return this.channel.canPush()}getSession(){return this.el.getAttribute(gt)}getStatic(){let t=this.el.getAttribute(Ht);return t===""?null:t}destroy(t=function(){}){this.destroyAllChildren(),this.destroyed=!0,delete this.root.children[this.id],this.parent&&delete this.root.children[this.parent.id][this.id],clearTimeout(this.loaderTimer);let i=()=>{t();for(let s in this.viewHooks)this.destroyHook(this.viewHooks[s])};p.markPhxChildDestroyed(this.el),this.log("destroyed",()=>["the child has been removed from the parent"]),this.channel.leave().receive("ok",i).receive("error",i).receive("timeout",i)}setContainerClasses(...t){this.el.classList.remove(ys,Xt,se,Ss,ye),this.el.classList.add(...t)}showLoader(t){if(clearTimeout(this.loaderTimer),t)this.loaderTimer=setTimeout(()=>this.showLoader(),t);else{for(let i in this.viewHooks)this.viewHooks[i].__disconnected();this.setContainerClasses(Xt)}}execAll(t){p.all(this.el,`[${t}]`,i=>this.liveSocket.execJS(i,i.getAttribute(t)))}hideLoader(){clearTimeout(this.loaderTimer),this.setContainerClasses(ys),this.execAll(this.binding("connected"))}triggerReconnected(){for(let t in this.viewHooks)this.viewHooks[t].__reconnected()}log(t,i){this.liveSocket.log(this,t,i)}transition(t,i,s=function(){}){this.liveSocket.transition(t,i,s)}withinTargets(t,i,s=document,r){if(t instanceof HTMLElement||t instanceof SVGElement)return this.liveSocket.owner(t,n=>i(n,t));if(wt(t))p.findComponentNodeList(r||this.el,t).length===0?rt(`no component found matching phx-target of ${t}`):i(this,parseInt(t));else{let n=Array.from(s.querySelectorAll(t));n.length===0&&rt(`nothing found matching the phx-target selector "${t}"`),n.forEach(o=>this.liveSocket.owner(o,a=>i(a,o)))}}applyDiff(t,i,s){this.log(t,()=>["",ke(i)]);let{diff:r,reply:n,events:o,title:a}=Be.extract(i);s({diff:r,reply:n,events:o}),(typeof a=="string"||t=="mount")&&window.requestAnimationFrame(()=>p.putTitle(a))}onJoin(t){let{rendered:i,container:s,liveview_version:r}=t;if(s){let[n,o]=s;this.el=p.replaceRootContainer(this.el,n,o)}this.childJoins=0,this.joinPending=!0,this.flash=null,this.root===this&&(this.formsForRecovery=this.getFormsForRecovery()),this.isMain()&&window.history.state===null&&this.liveSocket.replaceRootHistory(),r!==this.liveSocket.version()&&console.error(`LiveView asset version mismatch. JavaScript version ${this.liveSocket.version()} vs. server ${r}. To avoid issues, please ensure that your assets use the same version as the server.`),_t.dropLocal(this.liveSocket.localStorage,window.location.pathname,ci),this.applyDiff("mount",i,({diff:n,events:o})=>{this.rendered=new Be(this.id,n);let[a,l]=this.renderContainer(null,"join");this.dropPendingRefs(),this.joinCount++,this.joinAttempts=0,this.maybeRecoverForms(a,()=>{this.onJoinComplete(t,a,l,o)})})}dropPendingRefs(){p.all(document,`[${at}="${this.refSrc()}"]`,t=>{t.removeAttribute(Bt),t.removeAttribute(at),t.removeAttribute(ct)})}onJoinComplete({live_patch:t},i,s,r){if(this.joinCount>1||this.parent&&!this.parent.isJoinPending())return this.applyJoinPatch(t,i,s,r);p.findPhxChildrenInFragment(i,this.id).filter(o=>{let a=o.id&&this.el.querySelector(`[id="${o.id}"]`),l=a&&a.getAttribute(Ht);return l&&o.setAttribute(Ht,l),a&&a.setAttribute(Et,this.root.id),this.joinChild(o)}).length===0?this.parent?(this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(t,i,s,r)]),this.parent.ackJoin(this)):(this.onAllChildJoinsComplete(),this.applyJoinPatch(t,i,s,r)):this.root.pendingJoinOps.push([this,()=>this.applyJoinPatch(t,i,s,r)])}attachTrueDocEl(){this.el=p.byId(this.id),this.el.setAttribute(Et,this.root.id)}execNewMounted(t=this.el){let i=this.binding(Ne),s=this.binding(Fe);p.all(t,`[${i}], [${s}]`,r=>{this.ownsElement(r)&&(p.maintainPrivateHooks(r,r,i,s),this.maybeAddNewHook(r))}),p.all(t,`[${this.binding(Ee)}], [data-phx-${Ee}]`,r=>{this.ownsElement(r)&&this.maybeAddNewHook(r)}),p.all(t,`[${this.binding(Ts)}]`,r=>{this.ownsElement(r)&&this.maybeMounted(r)})}applyJoinPatch(t,i,s,r){this.attachTrueDocEl();let n=new he(this,this.el,this.id,i,s,null);if(n.markPrunableContentForRemoval(),this.performPatch(n,!1,!0),this.joinNewChildren(),this.execNewMounted(),this.joinPending=!1,this.liveSocket.dispatchEvents(r),this.applyPendingUpdates(),t){let{kind:o,to:a}=t;this.liveSocket.historyPatch(a,o)}this.hideLoader(),this.joinCount>1&&this.triggerReconnected(),this.stopCallback()}triggerBeforeUpdateHook(t,i){this.liveSocket.triggerDOM("onBeforeElUpdated",[t,i]);let s=this.getHook(t),r=s&&p.isIgnored(t,this.binding(oe));if(s&&!t.isEqualNode(i)&&!(r&&un(t.dataset,i.dataset)))return s.__beforeUpdate(),s}maybeMounted(t){let i=t.getAttribute(this.binding(Ts)),s=i&&p.private(t,"mounted");i&&!s&&(this.liveSocket.execJS(t,i),p.putPrivate(t,"mounted",!0))}maybeAddNewHook(t){let i=this.addHook(t);i&&i.__mounted()}performPatch(t,i,s=!1){let r=[],n=!1,o=new Set;return this.liveSocket.triggerDOM("onPatchStart",[t.targetContainer]),t.after("added",a=>{this.liveSocket.triggerDOM("onNodeAdded",[a]);let l=this.binding(Ne),h=this.binding(Fe);p.maintainPrivateHooks(a,a,l,h),this.maybeAddNewHook(a),a.getAttribute&&this.maybeMounted(a)}),t.after("phxChildAdded",a=>{p.isPhxSticky(a)?this.liveSocket.joinRootViews():n=!0}),t.before("updated",(a,l)=>{this.triggerBeforeUpdateHook(a,l)&&o.add(a.id)}),t.after("updated",a=>{o.has(a.id)&&this.getHook(a).__updated()}),t.after("discarded",a=>{a.nodeType===Node.ELEMENT_NODE&&r.push(a)}),t.after("transitionsDiscarded",a=>this.afterElementsRemoved(a,i)),t.perform(s),this.afterElementsRemoved(r,i),this.liveSocket.triggerDOM("onPatchEnd",[t.targetContainer]),n}afterElementsRemoved(t,i){let s=[];t.forEach(r=>{let n=p.all(r,`[${yt}]`),o=p.all(r,`[${this.binding(Ee)}], [data-phx-hook]`);n.concat(r).forEach(a=>{let l=this.componentID(a);wt(l)&&s.indexOf(l)===-1&&s.push(l)}),o.concat(r).forEach(a=>{let l=this.getHook(a);l&&this.destroyHook(l)})}),i&&this.maybePushComponentsDestroyed(s)}joinNewChildren(){p.findPhxChildren(this.el,this.id).forEach(t=>this.joinChild(t))}maybeRecoverForms(t,i){let s=this.binding("change"),r=this.root.formsForRecovery,n=document.createElement("template");n.innerHTML=t;let o=n.content.firstElementChild;o.id=this.id,o.setAttribute(Et,this.root.id),o.setAttribute(gt,this.getSession()),o.setAttribute(Ht,this.getStatic()),o.setAttribute(qt,this.parent?this.parent.id:null);let a=p.all(n.content,"form").filter(l=>l.id&&r[l.id]).filter(l=>!this.pendingForms.has(l.id)).filter(l=>r[l.id].getAttribute(s)===l.getAttribute(s)).map(l=>[r[l.id],l]);if(a.length===0)return i();a.forEach(([l,h],d)=>{this.pendingForms.add(h.id),this.pushFormRecovery(l,h,n.content.firstElementChild,()=>{this.pendingForms.delete(h.id),d===a.length-1&&i()})})}getChildById(t){return this.root.children[this.id][t]}getDescendentByEl(t){var i;return t.id===this.id?this:(i=this.children[t.getAttribute(qt)])==null?void 0:i[t.id]}destroyDescendent(t){for(let i in this.root.children)for(let s in this.root.children[i])if(s===t)return this.root.children[i][s].destroy()}joinChild(t){if(!this.getChildById(t.id)){let s=new ce(t,this.liveSocket,this);return this.root.children[this.id][s.id]=s,s.join(),this.childJoins++,!0}}isJoinPending(){return this.joinPending}ackJoin(t){this.childJoins--,this.childJoins===0&&(this.parent?this.parent.ackJoin(this):this.onAllChildJoinsComplete())}onAllChildJoinsComplete(){this.pendingForms.clear(),this.formsForRecovery={},this.joinCallback(()=>{this.pendingJoinOps.forEach(([t,i])=>{t.isDestroyed()||i()}),this.pendingJoinOps=[]})}update(t,i){if(this.isJoinPending()||this.liveSocket.hasPendingLink()&&this.root.isMain())return this.pendingDiffs.push({diff:t,events:i});this.rendered.mergeDiff(t);let s=!1;this.rendered.isComponentOnlyDiff(t)?this.liveSocket.time("component patch complete",()=>{p.findExistingParentCIDs(this.el,this.rendered.componentCIDs(t)).forEach(n=>{this.componentPatch(this.rendered.getComponent(t,n),n)&&(s=!0)})}):Ds(t)||this.liveSocket.time("full patch complete",()=>{let[r,n]=this.renderContainer(t,"update"),o=new he(this,this.el,this.id,r,n,null);s=this.performPatch(o,!0)}),this.liveSocket.dispatchEvents(i),s&&this.joinNewChildren()}renderContainer(t,i){return this.liveSocket.time(`toString diff (${i})`,()=>{let s=this.el.tagName,r=t?this.rendered.componentCIDs(t):null,[n,o]=this.rendered.toString(r);return[`<${s}>${n}`,o]})}componentPatch(t,i){if(Ds(t))return!1;let[s,r]=this.rendered.componentToString(i),n=new he(this,this.el,this.id,s,r,i);return this.performPatch(n,!0)}getHook(t){return this.viewHooks[Ft.elementID(t)]}addHook(t){let i=Ft.elementID(t);if(i&&!this.viewHooks[i]){let s=p.getCustomElHook(t)||rt(`no hook found for custom element: ${t.id}`);return this.viewHooks[i]=s,s.__attachView(this),s}else{if(i||!t.getAttribute)return;{let s=t.getAttribute(`data-phx-${Ee}`)||t.getAttribute(this.binding(Ee));if(s&&!this.ownsElement(t))return;let r=this.liveSocket.getHookCallbacks(s);if(r){t.id||rt(`no DOM ID for hook "${s}". Hooks require a unique ID on each element.`,t);let n=new Ft(this,t,r);return this.viewHooks[Ft.elementID(n.el)]=n,n}else s!==null&&rt(`unknown hook found for "${s}"`,t)}}}destroyHook(t){t.__destroyed(),t.__cleanup__(),delete this.viewHooks[Ft.elementID(t.el)]}applyPendingUpdates(){this.pendingDiffs.forEach(({diff:t,events:i})=>this.update(t,i)),this.pendingDiffs=[],this.eachChild(t=>t.applyPendingUpdates())}eachChild(t){let i=this.root.children[this.id]||{};for(let s in i)t(this.getChildById(s))}onChannel(t,i){this.liveSocket.onChannel(this.channel,t,s=>{this.isJoinPending()?this.root.pendingJoinOps.push([this,()=>i(s)]):this.liveSocket.requestDOMUpdate(()=>i(s))})}bindChannel(){this.liveSocket.onChannel(this.channel,"diff",t=>{this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",t,({diff:i,events:s})=>this.update(i,s))})}),this.onChannel("redirect",({to:t,flash:i})=>this.onRedirect({to:t,flash:i})),this.onChannel("live_patch",t=>this.onLivePatch(t)),this.onChannel("live_redirect",t=>this.onLiveRedirect(t)),this.channel.onError(t=>this.onError(t)),this.channel.onClose(t=>this.onClose(t))}destroyAllChildren(){this.eachChild(t=>t.destroy())}onLiveRedirect(t){let{to:i,kind:s,flash:r}=t,n=this.expandURL(i),o=new CustomEvent(`${M}:server-navigate`,{detail:{to:i,kind:s,flash:r}});this.liveSocket.historyRedirect(o,n,s,r)}onLivePatch(t){let{to:i,kind:s}=t;this.href=this.expandURL(i),this.liveSocket.historyPatch(i,s)}expandURL(t){return t.startsWith("/")?`${window.location.protocol}//${window.location.host}${t}`:t}onRedirect({to:t,flash:i,reloadToken:s}){this.liveSocket.redirect(t,i,s)}isDestroyed(){return this.destroyed}joinDead(){this.isDead=!0}joinPush(){return this.joinPush=this.joinPush||this.channel.join(),this.joinPush}join(t){this.showLoader(this.liveSocket.loaderTimeout),this.bindChannel(),this.isMain()&&(this.stopCallback=this.liveSocket.withPageLoading({to:this.href,kind:"initial"})),this.joinCallback=i=>{i=i||function(){},t?t(this.joinCount,i):i()},this.wrapPush(()=>this.channel.join(),{ok:i=>this.liveSocket.requestDOMUpdate(()=>this.onJoin(i)),error:i=>this.onJoinError(i),timeout:()=>this.onJoinError({reason:"timeout"})})}onJoinError(t){if(t.reason==="reload"){this.log("error",()=>[`failed mount with ${t.status}. Falling back to page reload`,t]),this.onRedirect({to:this.root.href,reloadToken:t.token});return}else if(t.reason==="unauthorized"||t.reason==="stale"){this.log("error",()=>["unauthorized live_redirect. Falling back to page request",t]),this.onRedirect({to:this.root.href});return}if((t.redirect||t.live_redirect)&&(this.joinPending=!1,this.channel.leave()),t.redirect)return this.onRedirect(t.redirect);if(t.live_redirect)return this.onLiveRedirect(t.live_redirect);if(this.log("error",()=>["unable to join",t]),this.isMain())this.displayError([Xt,se,ye]),this.liveSocket.isConnected()&&this.liveSocket.reloadWithJitter(this);else{this.joinAttempts>=xs&&(this.root.displayError([Xt,se,ye]),this.log("error",()=>[`giving up trying to mount after ${xs} tries`,t]),this.destroy());let i=p.byId(this.el.id);i?(p.mergeAttrs(i,this.el),this.displayError([Xt,se,ye]),this.el=i):this.destroy()}}onClose(t){if(!this.isDestroyed()){if(this.isMain()&&this.liveSocket.hasPendingLink()&&t!=="leave")return this.liveSocket.reloadWithJitter(this);this.destroyAllChildren(),this.liveSocket.dropActiveElement(this),document.activeElement&&document.activeElement.blur(),this.liveSocket.isUnloaded()&&this.showLoader(nn)}}onError(t){this.onClose(t),this.liveSocket.isConnected()&&this.log("error",()=>["view crashed",t]),this.liveSocket.isUnloaded()||(this.liveSocket.isConnected()?this.displayError([Xt,se,ye]):this.displayError([Xt,se,Ss]))}displayError(t){this.isMain()&&p.dispatchEvent(window,`${M}:page-loading-start`,{detail:{to:this.href,kind:"error"}}),this.showLoader(),this.setContainerClasses(...t),this.execAll(this.binding("disconnected"))}wrapPush(t,i){let s=this.liveSocket.getLatencySim(),r=s?n=>setTimeout(()=>!this.isDestroyed()&&n(),s):n=>!this.isDestroyed()&&n();r(()=>{t().receive("ok",n=>r(()=>i.ok&&i.ok(n))).receive("error",n=>r(()=>i.error&&i.error(n))).receive("timeout",()=>r(()=>i.timeout&&i.timeout()))})}pushWithReply(t,i,s){if(!this.isConnected())return Promise.reject({error:"noconnection"});let[r,[n],o]=t?t():[null,[],{}],a=this.joinCount,l=function(){};return o.page_loading&&(l=this.liveSocket.withPageLoading({kind:"element",target:n})),typeof s.cid!="number"&&delete s.cid,new Promise((h,d)=>{this.wrapPush(()=>this.channel.push(i,s,an),{ok:f=>{r!==null&&(this.lastAckRef=r);let b=v=>{f.redirect&&this.onRedirect(f.redirect),f.live_patch&&this.onLivePatch(f.live_patch),f.live_redirect&&this.onLiveRedirect(f.live_redirect),l(),h({resp:f,reply:v})};f.diff?this.liveSocket.requestDOMUpdate(()=>{this.applyDiff("update",f.diff,({diff:v,reply:g,events:y})=>{r!==null&&this.undoRefs(r,s.event),this.update(v,y),b(g)})}):(r!==null&&this.undoRefs(r,s.event),b(null))},error:f=>d({error:f}),timeout:()=>{d({timeout:!0}),this.joinCount===a&&this.liveSocket.reloadWithJitter(this,()=>{this.log("timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}})})}undoRefs(t,i,s){if(!this.isConnected())return;let r=`[${at}="${this.refSrc()}"]`;s?(s=new Set(s),p.all(document,r,n=>{s&&!s.has(n)||(p.all(n,r,o=>this.undoElRef(o,t,i)),this.undoElRef(n,t,i))})):p.all(document,r,n=>this.undoElRef(n,t,i))}undoElRef(t,i,s){new wi(t).maybeUndo(i,s,n=>{let o=this.triggerBeforeUpdateHook(t,n);he.patchWithClonedTree(t,n,this.liveSocket),p.all(t,`[${at}="${this.refSrc()}"]`,a=>this.undoElRef(a,i,s)),this.execNewMounted(t),o&&o.__updated()})}refSrc(){return this.el.id}putRef(t,i,s,r={}){let n=this.ref++,o=this.binding(Cs);if(r.loading){let a=p.all(document,r.loading).map(l=>({el:l,lock:!0,loading:!0}));t=t.concat(a)}for(let{el:a,lock:l,loading:h}of t){if(!l&&!h)throw new Error("putRef requires lock or loading");if(a.setAttribute(at,this.refSrc()),h&&a.setAttribute(Bt,n),l&&a.setAttribute(ct,n),!h||r.submitter&&!(a===r.submitter||a===r.form))continue;let d=new Promise(g=>{a.addEventListener(`${M}:undo-lock:${n}`,()=>g(v),{once:!0})}),f=new Promise(g=>{a.addEventListener(`${M}:undo-loading:${n}`,()=>g(v),{once:!0})});a.classList.add(`phx-${s}-loading`);let b=a.getAttribute(o);b!==null&&(a.getAttribute(Se)||a.setAttribute(Se,a.innerText),b!==""&&(a.innerText=b),a.setAttribute(Wt,a.getAttribute(Wt)||a.disabled),a.setAttribute("disabled",""));let v={event:i,eventType:s,ref:n,isLoading:h,isLocked:l,lockElements:t.filter(({lock:g})=>g).map(({el:g})=>g),loadingElements:t.filter(({loading:g})=>g).map(({el:g})=>g),unlock:g=>{g=Array.isArray(g)?g:[g],this.undoRefs(n,i,g)},lockComplete:d,loadingComplete:f,lock:g=>new Promise(y=>{if(this.isAcked(n))return y(v);g.setAttribute(ct,n),g.setAttribute(at,this.refSrc()),g.addEventListener(`${M}:lock-stop:${n}`,()=>y(v),{once:!0})})};a.dispatchEvent(new CustomEvent(`${M}:push`,{detail:v,bubbles:!0,cancelable:!1})),i&&a.dispatchEvent(new CustomEvent(`${M}:push:${i}`,{detail:v,bubbles:!0,cancelable:!1}))}return[n,t.map(({el:a})=>a),r]}isAcked(t){return this.lastAckRef!==null&&this.lastAckRef>=t}componentID(t){let i=t.getAttribute&&t.getAttribute(yt);return i?parseInt(i):null}targetComponentID(t,i,s={}){if(wt(i))return i;let r=s.target||t.getAttribute(this.binding("target"));return wt(r)?parseInt(r):i&&(r!==null||s.target)?this.closestComponentID(i):null}closestComponentID(t){return wt(t)?t:t?xt(t.closest(`[${yt}]`),i=>this.ownsElement(i)&&this.componentID(i)):null}pushHookEvent(t,i,s,r,n){if(!this.isConnected())return this.log("hook",()=>["unable to push hook event. LiveView not connected",s,r]),!1;let[o,a,l]=this.putRef([{el:t,loading:!0,lock:!0}],s,"hook");return this.pushWithReply(()=>[o,a,l],"event",{type:"hook",event:s,value:r,cid:this.closestComponentID(i)}).then(({resp:h,reply:d})=>n(d,o)),o}extractMeta(t,i,s){let r=this.binding("value-");for(let n=0;n=0&&!t.checked&&delete i.value),s){i||(i={});for(let n in s)i[n]=s[n]}return i}pushEvent(t,i,s,r,n,o={},a){this.pushWithReply(()=>this.putRef([{el:i,loading:!0,lock:!0}],r,t,o),"event",{type:t,event:r,value:this.extractMeta(i,n,o.value),cid:this.targetComponentID(i,s,o)}).then(({reply:l})=>a&&a(l))}pushFileProgress(t,i,s,r=function(){}){this.liveSocket.withinOwners(t.form,(n,o)=>{n.pushWithReply(null,"progress",{event:t.getAttribute(n.binding(sn)),ref:t.getAttribute(St),entry_ref:i,progress:s,cid:n.targetComponentID(t.form,o)}).then(({resp:a})=>r(a))})}pushInput(t,i,s,r,n,o){if(!t.form)throw new Error("form events require the input to be inside a form");let a,l=wt(s)?s:this.targetComponentID(t.form,i,n),h=()=>this.putRef([{el:t,loading:!0,lock:!0},{el:t.form,loading:!0,lock:!0}],r,"change",n),d,f=this.extractMeta(t.form);t instanceof HTMLButtonElement&&(f.submitter=t),t.getAttribute(this.binding("change"))?d=ki(t.form,P({_target:n._target},f),[t.name]):d=ki(t.form,P({_target:n._target},f)),p.isUploadInput(t)&&t.files&&t.files.length>0&&W.trackFiles(t,Array.from(t.files)),a=W.serializeUploads(t);let b={type:"form",event:r,value:d,uploads:a,cid:l};this.pushWithReply(h,"event",b).then(({resp:v})=>{if(p.isUploadInput(t)&&p.isAutoUpload(t)){if(W.filesAwaitingPreflight(t).length>0){let[g,y]=h();this.undoRefs(g,r,[t.form]),this.uploadFiles(t.form,r,i,g,l,C=>{o&&o(v),this.triggerAwaitingSubmit(t.form,r),this.undoRefs(g,r)})}}else o&&o(v)})}triggerAwaitingSubmit(t,i){let s=this.getScheduledSubmit(t);if(s){let[r,n,o,a]=s;this.cancelSubmit(t,i),a()}}getScheduledSubmit(t){return this.formSubmits.find(([i,s,r,n])=>i.isSameNode(t))}scheduleSubmit(t,i,s,r){if(this.getScheduledSubmit(t))return!0;this.formSubmits.push([t,i,s,r])}cancelSubmit(t,i){this.formSubmits=this.formSubmits.filter(([s,r,n,o])=>s.isSameNode(t)?(this.undoRefs(r,i),!1):!0)}disableForm(t,i,s={}){let r=g=>!(xe(g,`${this.binding(oe)}=ignore`,g.form)||xe(g,"data-phx-update=ignore",g.form)),n=g=>g.hasAttribute(this.binding(Cs)),o=g=>g.tagName=="BUTTON",a=g=>["INPUT","TEXTAREA","SELECT"].includes(g.tagName),l=Array.from(t.elements),h=l.filter(n),d=l.filter(o).filter(r),f=l.filter(a).filter(r);d.forEach(g=>{g.setAttribute(Wt,g.disabled),g.disabled=!0}),f.forEach(g=>{g.setAttribute(Ue,g.readOnly),g.readOnly=!0,g.files&&(g.setAttribute(Wt,g.disabled),g.disabled=!0)});let b=h.concat(d).concat(f).map(g=>({el:g,loading:!0,lock:!0})),v=[{el:t,loading:!0,lock:!1}].concat(b).reverse();return this.putRef(v,i,"submit",s)}pushFormSubmit(t,i,s,r,n,o){let a=()=>this.disableForm(t,s,Z(P({},n),{form:t,submitter:r})),l=this.targetComponentID(t,i);if(W.hasUploadsInProgress(t)){let[h,d]=a(),f=()=>this.pushFormSubmit(t,i,s,r,n,o);return this.scheduleSubmit(t,h,n,f)}else if(W.inputsAwaitingPreflight(t).length>0){let[h,d]=a(),f=()=>[h,d,n];this.uploadFiles(t,s,i,h,l,b=>{if(W.inputsAwaitingPreflight(t).length>0)return this.undoRefs(h,s);let v=this.extractMeta(t),g=ki(t,P({submitter:r},v));this.pushWithReply(f,"event",{type:"form",event:s,value:g,cid:l}).then(({resp:y})=>o(y))})}else if(!(t.hasAttribute(at)&&t.classList.contains("phx-submit-loading"))){let h=this.extractMeta(t),d=ki(t,P({submitter:r},h));this.pushWithReply(a,"event",{type:"form",event:s,value:d,cid:l}).then(({resp:f})=>o(f))}}uploadFiles(t,i,s,r,n,o){let a=this.joinCount,l=W.activeFileInputs(t),h=l.length;l.forEach(d=>{let f=new W(d,this,()=>{h--,h===0&&o()}),b=f.entries().map(g=>g.toPreflightPayload());if(b.length===0){h--;return}let v={ref:d.getAttribute(St),entries:b,cid:this.targetComponentID(d.form,s)};this.log("upload",()=>["sending preflight request",v]),this.pushWithReply(null,"allow_upload",v).then(({resp:g})=>{if(this.log("upload",()=>["got preflight response",g]),f.entries().forEach(y=>{g.entries&&!g.entries[y.ref]&&this.handleFailedEntryPreflight(y.ref,"failed preflight",f)}),g.error||Object.keys(g.entries).length===0)this.undoRefs(r,i),(g.error||[]).map(([C,D])=>{this.handleFailedEntryPreflight(C,D,f)});else{let y=C=>{this.channel.onError(()=>{this.joinCount===a&&C()})};f.initAdapterUpload(g,y,this.liveSocket)}})})}handleFailedEntryPreflight(t,i,s){if(s.isAutoUpload()){let r=s.entries().find(n=>n.ref===t.toString());r&&r.cancel()}else s.entries().map(r=>r.cancel());this.log("upload",()=>[`error for entry ${t}`,i])}dispatchUploads(t,i,s){let r=this.targetCtxElement(t)||this.el,n=p.findUploadInputs(r).filter(o=>o.name===i);n.length===0?rt(`no live file inputs found matching the name "${i}"`):n.length>1?rt(`duplicate live file inputs found matching the name "${i}"`):p.dispatchEvent(n[0],ui,{detail:{files:s}})}targetCtxElement(t){if(wt(t)){let[i]=p.findComponentNodeList(this.el,t);return i}else return t||null}pushFormRecovery(t,i,s,r){let n=this.binding("change"),o=i.getAttribute(this.binding("target"))||i,a=i.getAttribute(this.binding(As))||i.getAttribute(this.binding("change")),l=Array.from(t.elements).filter(f=>p.isFormInput(f)&&f.name&&!f.hasAttribute(n));if(l.length===0)return;l.forEach(f=>f.hasAttribute(St)&&W.clearFiles(f));let h=l.find(f=>f.type!=="hidden")||l[0],d=0;this.withinTargets(o,(f,b)=>{let v=this.targetComponentID(i,b);d++;let g=new CustomEvent(`${M}:form-recovery`,{detail:{sourceElement:t}});j.exec(g,"change",a,this,h,["push",{_target:h.name,targetView:f,targetCtx:b,newCid:v,callback:()=>{d--,d===0&&r()}}])},s,s)}pushLinkPatch(t,i,s,r){let n=this.liveSocket.setPendingLink(i),o=t.isTrusted&&t.type!=="popstate",a=s?()=>this.putRef([{el:s,loading:o,lock:!0}],null,"click"):null,l=()=>this.liveSocket.redirect(window.location.href),h=i.startsWith("/")?`${location.protocol}//${location.host}${i}`:i;this.pushWithReply(a,"live_patch",{url:h}).then(({resp:d})=>{this.liveSocket.requestDOMUpdate(()=>{d.link_redirect?this.liveSocket.replaceMain(i,null,r,n):(this.liveSocket.commitPendingLink(n)&&(this.href=i),this.applyPendingUpdates(),r&&r(n))})},({error:d,timeout:f})=>l())}getFormsForRecovery(){if(this.joinCount===0)return{};let t=this.binding("change");return p.all(this.el,`form[${t}]`).filter(i=>i.id).filter(i=>i.elements.length>0).filter(i=>i.getAttribute(this.binding(As))!=="ignore").map(i=>i.cloneNode(!0)).reduce((i,s)=>(i[s.id]=s,i),{})}maybePushComponentsDestroyed(t){let i=t.filter(s=>p.findComponentNodeList(this.el,s).length===0);i.length>0&&(i.forEach(s=>this.rendered.resetRender(s)),this.pushWithReply(null,"cids_will_destroy",{cids:i}).then(()=>{this.liveSocket.requestDOMUpdate(()=>{let s=i.filter(r=>p.findComponentNodeList(this.el,r).length===0);s.length>0&&this.pushWithReply(null,"cids_destroyed",{cids:s}).then(({resp:r})=>{this.rendered.pruneCIDs(r.cids)})})}))}ownsElement(t){let i=t.closest(Ot);return t.getAttribute(qt)===this.id||i&&i.id===this.id||!i&&this.isDead}submitForm(t,i,s,r,n={}){p.putPrivate(t,ne,!0),Array.from(t.elements).forEach(a=>p.putPrivate(a,ne,!0)),this.liveSocket.blurActiveElement(this),this.pushFormSubmit(t,i,s,r,n,()=>{this.liveSocket.restorePreviouslyActiveFocus()})}binding(t){return this.liveSocket.binding(t)}};var Xe=class{constructor(t,i,s={}){if(this.unloaded=!1,!i||i.constructor.name==="Object")throw new Error(` a phoenix Socket must be provided as the second argument to the LiveSocket constructor. For example: import {Socket} from "phoenix" import {LiveSocket} from "phoenix_live_view" let liveSocket = new LiveSocket("/live", Socket, {...}) `);this.socket=new i(t,s),this.bindingPrefix=s.bindingPrefix||on,this.opts=s,this.params=Te(s.params||{}),this.viewLogger=s.viewLogger,this.metadataCallbacks=s.metadata||{},this.defaults=Object.assign(ke(ln),s.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=ke(window.location),this.hooks=s.hooks||{},this.uploaders=s.uploaders||{},this.loaderTimeout=s.loaderTimeout||rn,this.reloadWithJitterTimer=null,this.maxReloads=s.maxReloads||Wr,this.reloadJitterMin=s.reloadJitterMin||Kr,this.reloadJitterMax=s.reloadJitterMax||zr,this.failsafeJitter=s.failsafeJitter||Jr,this.localStorage=s.localStorage||window.localStorage,this.sessionStorage=s.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.boundEventNames=new Set,this.serverCloseRef=null,this.domCallbacks=Object.assign({jsQuerySelectorAll:null,onPatchStart:Te(),onPatchEnd:Te(),onNodeAdded:Te(),onBeforeElUpdated:Te()},s.dom||{}),this.doofinderMount=s.doofinderMount,this.connectCallback=s.connectCallback||(()=>{}),this.disconnectCallback=s.disconnectCallback||(()=>{}),this.unbindFunctions=[],this.transitions=new wn,this.currentHistoryPosition=parseInt(this.sessionStorage.getItem(yi))||0,window.addEventListener("pagehide",r=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()}),this.socket.onOpen(()=>{this.connectCallback()})}version(){return"1.0.2"}isProfileEnabled(){return this.sessionStorage.getItem(vi)==="true"}isDebugEnabled(){return this.sessionStorage.getItem($e)==="true"}isDebugDisabled(){return this.sessionStorage.getItem($e)==="false"}enableDebug(){this.sessionStorage.setItem($e,"true")}enableProfiling(){this.sessionStorage.setItem(vi,"true")}disableDebug(){this.sessionStorage.setItem($e,"false")}disableProfiling(){this.sessionStorage.removeItem(vi)}enableLatencySim(t){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(bi,t)}disableLatencySim(){this.sessionStorage.removeItem(bi)}getLatencySim(){let t=this.sessionStorage.getItem(bi);return t?parseInt(t):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug(),this.joinRootViews()&&(this.bindTopLevelEvents(),this.socket.connect())}disconnect(t){clearTimeout(this.reloadWithJitterTimer),this.serverCloseRef&&(this.socket.off(this.serverCloseRef),this.serverCloseRef=null),this.socket.disconnect(t)}replaceTransport(t){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(t),this.connect()}execJS(t,i,s=null){let r=new CustomEvent(`${M}:exec`,{detail:{sourceElement:t}});this.owner(t,n=>j.exec(r,s,i,n,t))}execJSHookPush(t,i,s,r){this.withinOwners(t,n=>{let o=new CustomEvent(`${M}:exec`,{detail:{sourceElement:t}});j.exec(o,"hook",i,n,t,["push",{data:s,callback:r}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(t,i){this.domCallbacks[t](...i)}time(t,i){if(!this.isProfileEnabled()||!console.time)return i();console.time(t);let s=i();return console.timeEnd(t),s}log(t,i,s){if(this.viewLogger){let[r,n]=s();this.viewLogger(t,i,r,n)}else if(this.isDebugEnabled()){let[r,n]=s();dn(t,i,r,n)}}requestDOMUpdate(t){this.transitions.after(t)}transition(t,i,s=function(){}){this.transitions.addTransition(t,i,s)}onChannel(t,i,s){t.on(i,r=>{let n=this.getLatencySim();n?setTimeout(()=>s(r),n):s(r)})}reloadWithJitter(t,i){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let s=this.reloadJitterMin,r=this.reloadJitterMax,n=Math.floor(Math.random()*(r-s+1))+s;_t.updateLocal(this.localStorage,window.location.pathname,ci,0,a=>a+1)>=this.maxReloads&&(n=this.failsafeJitter),this.reloadWithJitterTimer=setTimeout(()=>{this.disconnectCallback()},n)}getHookCallbacks(t){return t&&t.startsWith("Phoenix.")?pn[t.split(".")[1]]:this.hooks[t]}isUnloaded(){return this.unloaded}isConnected(){return this.socket.isConnected()}getBindingPrefix(){return this.bindingPrefix}binding(t){return`${this.getBindingPrefix()}${t}`}channel(t,i){return this.socket.channel(t,i)}joinRootViews(){if(this.doofinderMount){let t=this.newRootView(this.doofinderMount);return t.setHref(this.getHref()),t.join(),this.main=t,!0}else return!1}redirect(t,i,s){s&&_t.setCookie(ks,s,60),this.unload(),_t.redirect(t,i)}replaceMain(t,i,s=null,r=this.setPendingLink(t)){let n=this.currentLocation.href;this.outgoingMainEl=this.outgoingMainEl||this.main.el;let o=p.all(this.outgoingMainEl,`[${this.binding("remove")}]`),a=p.cloneNode(this.outgoingMainEl,"");this.main.showLoader(this.loaderTimeout),this.main.destroy(),this.main=this.newRootView(a,i,n),this.main.setRedirect(t),this.transitionRemoves(o,!0),this.main.join((l,h)=>{l===1&&this.commitPendingLink(r)&&this.requestDOMUpdate(()=>{o.forEach(d=>d.remove()),p.findPhxSticky(document).forEach(d=>a.appendChild(d)),this.outgoingMainEl.replaceWith(a),this.outgoingMainEl=null,s&&s(r),h()})})}transitionRemoves(t,i,s){let r=this.binding("remove");if(i){let o=p.findPhxSticky(document)||[];t=t.filter(a=>!p.isChildOfAny(a,o))}let n=o=>{o.preventDefault(),o.stopImmediatePropagation()};t.forEach(o=>{for(let a of this.boundEventNames)o.addEventListener(a,n,!0);this.execJS(o,o.getAttribute(r),"remove")}),this.requestDOMUpdate(()=>{t.forEach(o=>{for(let a of this.boundEventNames)o.removeEventListener(a,n,!0)}),s&&s()})}isPhxView(t){return t.getAttribute&&t.getAttribute(gt)!==null}newRootView(t,i,s){let r=new ce(t,this,null,i,s);return this.roots[r.id]=r,r}owner(t,i){let s=xt(t.closest(Ot),r=>this.getViewByEl(r))||this.main;return s&&i?i(s):s}withinOwners(t,i){this.owner(t,s=>i(s,t))}getViewByEl(t){let i=t.getAttribute(Et);return xt(this.getRootById(i),s=>s.getDescendentByEl(t))}getRootById(t){return this.roots[t]}destroyAllViews(){for(let t in this.roots)this.roots[t].destroy(),delete this.roots[t];this.main=null}destroyViewByEl(t){let i=this.getRootById(t.getAttribute(Et));i&&i.id===t.id?(i.destroy(),delete this.roots[i.id]):i&&i.destroyDescendent(t.id)}getActiveElement(){return document.activeElement}dropActiveElement(t){this.prevActive&&t.ownsElement(this.prevActive)&&(this.prevActive=null)}restorePreviouslyActiveFocus(){this.prevActive&&this.prevActive!==document.body&&this.prevActive.focus()}blurActiveElement(){this.prevActive=this.getActiveElement(),this.prevActive!==document.body&&this.prevActive.blur()}bindTopLevelEvents({dead:t}={}){this.boundTopLevelEvents||(this.boundTopLevelEvents=!0,this.serverCloseRef=this.socket.onClose(i=>{if(i&&i.code===1e3&&this.main)return this.reloadWithJitter(this.main)}),this.unbindFunctions.push((()=>{let i=function(){};return document.body.addEventListener("click",i),function(){document.body.removeEventListener("click",i)}})()),window.addEventListener("pageshow",i=>{i.persisted&&(this.getSocket().disconnect(),this.withPageLoading({to:window.location.href,kind:"redirect"}),window.location.reload())},!0),this.bindClicks(),t||this.bindForms(),this.bind({keyup:"keyup",keydown:"keydown"},(i,s,r,n,o,a)=>{let l=n.getAttribute(this.binding(en)),h=i.key&&i.key.toLowerCase();if(l&&l.toLowerCase()!==h)return;let d=P({key:i.key},this.eventMeta(s,i,n));j.exec(i,s,o,r,n,["push",{data:d}])}),this.bind({blur:"focusout",focus:"focusin"},(i,s,r,n,o,a)=>{if(!a){let l=P({key:i.key},this.eventMeta(s,i,n));j.exec(i,s,o,r,n,["push",{data:l}])}}),this.bind({blur:"blur",focus:"focus"},(i,s,r,n,o,a)=>{if(a==="window"){let l=this.eventMeta(s,i,n);j.exec(i,s,o,r,n,["push",{data:l}])}}),this.unbindFunctions.push((()=>{let i=s=>s.preventDefault();return this.doofinderMount.addEventListener("dragover",i),()=>this.doofinderMount.removeEventListener("dragover",i)})()),this.unbindFunctions.push((()=>{let i=s=>{s.preventDefault();let r=xt(xe(s.target,this.binding(vs)),a=>a.getAttribute(this.binding(vs))),n=r&&document.getElementById(r),o=Array.from(s.dataTransfer.files||[]);!n||n.disabled||o.length===0||!(n.files instanceof FileList)||(W.trackFiles(n,o,s.dataTransfer),n.dispatchEvent(new Event("input",{bubbles:!0})))};return this.doofinderMount.addEventListener("drop",i),()=>this.doofinderMount.removeEventListener("drop",i)})()),this.on(ui,i=>{let s=i.target;if(!p.isUploadInput(s))return;let r=Array.from(i.detail.files||[]).filter(n=>n instanceof File||n instanceof Blob);W.trackFiles(s,r),s.dispatchEvent(new Event("input",{bubbles:!0}))},this.doofinderMount))}unbindTopLevelEvents(){this.unbindFunctions.forEach(t=>t()),this.unbindFunctions=[]}eventMeta(t,i,s){let r=this.metadataCallbacks[t];return r?r(i,s):{}}setPendingLink(t){return this.linkRef++,this.pendingLink=t,this.resetReloadStatus(),this.linkRef}resetReloadStatus(){_t.deleteCookie(ks)}commitPendingLink(t){return this.linkRef!==t?!1:(this.href=this.pendingLink,this.pendingLink=null,!0)}getHref(){return this.href}hasPendingLink(){return!!this.pendingLink}bind(t,i){for(let s in t){let r=t[s];this.on(r,n=>{let o=this.binding(s),a=this.binding(`window-${s}`),l=n.target.getAttribute&&n.target.getAttribute(o);l?this.debounce(n.target,n,r,()=>{this.withinOwners(n.target,h=>{i(n,s,h,n.target,l,null)})}):p.all(document,`[${a}]`,h=>{let d=h.getAttribute(a);this.debounce(h,n,r,()=>{this.withinOwners(h,f=>{i(n,s,f,h,d,"window")})})})},this.doofinderMount)}}bindClicks(){let t=i=>{this.clickStartedAtTarget=i.target};this.doofinderMount.addEventListener("click",t),this.unbindFunctions.push(()=>this.doofinderMount.removeEventListener("click",t)),this.on("mousedown",i=>this.clickStartedAtTarget=i.target),this.bindClick("click","click",!1)}bindClick(t,i,s){let r=this.binding(i),n=o=>{let a=null;o.detail===0&&(this.clickStartedAtTarget=o.target);let l=this.clickStartedAtTarget||o.target;a=xe(o.target,r),this.dispatchClickAway(o,l),this.clickStartedAtTarget=null;let h=a&&a.getAttribute(r);if(!h){p.isNewPageClick(o,window.location)&&this.unload();return}a.getAttribute("href")==="#"&&o.preventDefault(),!a.hasAttribute(at)&&(a.disabled||this.debounce(a,o,"click",()=>{this.withinOwners(a,d=>{j.exec(o,"click",h,d,a,["push",{data:this.eventMeta("click",o,a)}])})}))};this.doofinderMount.addEventListener(t,n,!1),this.unbindFunctions.push(()=>this.doofinderMount.removeEventListener(t,n,!1))}dispatchClickAway(t,i){let s=this.binding("click-away");p.all(document,`[${s}]`,r=>{r.isSameNode(i)||r.contains(i)||this.withinOwners(r,n=>{let o=r.getAttribute(s);j.isVisible(r)&&j.isInViewport(r)&&j.exec(t,"click",o,n,r,["push",{data:this.eventMeta("click",t,t.target)}])})})}maybeScroll(t){typeof t=="number"&&requestAnimationFrame(()=>{window.scrollTo(0,t)})}dispatchEvent(t,i={}){p.dispatchEvent(this.doofinderMount,`${M}:${t}`,{detail:i})}dispatchEvents(t){t.forEach(([i,s])=>this.dispatchEvent(i,s))}withPageLoading(t,i){p.dispatchEvent(this.doofinderMount,`${M}:page-loading-start`,{detail:t});let s=()=>p.dispatchEvent(this.doofinderMount,`${M}:page-loading-stop`,{detail:t});return i?i(s):s}pushHistoryPatch(t,i,s,r){if(!this.isConnected()||!this.main.isMain())return _t.redirect(i);this.withPageLoading({to:i,kind:"patch"},n=>{this.main.pushLinkPatch(t,i,r,o=>{this.historyPatch(i,s,o),n()})})}historyPatch(t,i,s=this.setPendingLink(t)){!this.commitPendingLink(s)||(this.currentHistoryPosition++,this.sessionStorage.setItem(yi,this.currentHistoryPosition.toString()),_t.updateCurrentState(r=>Z(P({},r),{backType:"patch"})),_t.pushState(i,{type:"patch",id:this.main.id,position:this.currentHistoryPosition},t),p.dispatchEvent(window,`${M}:navigate`,{detail:{patch:!0,href:t,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location))}historyRedirect(t,i,s,r,n){if(n&&t.isTrusted&&t.type!=="popstate"&&n.classList.add("phx-click-loading"),!this.isConnected()||!this.main.isMain())return _t.redirect(i,r);if(/^\/$|^\/[^\/]+.*$/.test(i)){let{protocol:a,host:l}=window.location;i=`${a}//${l}${i}`}let o=window.scrollY;this.withPageLoading({to:i,kind:"redirect"},a=>{this.replaceMain(i,r,l=>{l===this.linkRef&&(this.currentHistoryPosition++,this.sessionStorage.setItem(yi,this.currentHistoryPosition.toString()),_t.updateCurrentState(h=>Z(P({},h),{backType:"redirect"})),_t.pushState(s,{type:"redirect",id:this.main.id,scroll:o,position:this.currentHistoryPosition},i),p.dispatchEvent(window,`${M}:navigate`,{detail:{href:i,patch:!1,pop:!1,direction:"forward"}}),this.registerNewLocation(window.location)),a()})})}replaceRootHistory(){_t.pushState("replace",{root:!0,type:"patch",id:this.main.id,position:this.currentHistoryPosition})}registerNewLocation(t){let{pathname:i,search:s}=this.currentLocation;return i+s===t.pathname+t.search?!1:(this.currentLocation=ke(t),!0)}bindForms(){let t=0,i=!1;this.on("submit",s=>{let r=s.target.getAttribute(this.binding("submit")),n=s.target.getAttribute(this.binding("change"));!i&&n&&!r&&(i=!0,s.preventDefault(),s.stopPropagation(),this.withinOwners(s.target,o=>{o.disableForm(s.target),window.requestAnimationFrame(()=>{p.isUnloadableFormSubmit(s)&&this.unload(),s.target.submit()})}))},this.doofinderMount),this.on("submit",s=>{let r=s.target.getAttribute(this.binding("submit"));if(!r){p.isUnloadableFormSubmit(s)&&this.unload();return}s.preventDefault(),s.stopPropagation(),s.target.disabled=!0,this.withinOwners(s.target,n=>{j.exec(s,"submit",r,n,s.target,["push",{submitter:s.submitter}])})},this.doofinderMount);for(let s of["change","input"])this.on(s,r=>{if(r.stopPropagation(),r instanceof CustomEvent&&r.target.form===void 0){if(r.detail&&r.detail.dispatcher)throw new Error(`dispatching a custom ${s} event is only supported on input elements inside a form`);return}let n=this.binding("change"),o=r.target;if(r.isComposing){let g=`composition-listener-${s}`;p.private(o,g)||(p.putPrivate(o,g,!0),o.addEventListener("compositionend",()=>{o.dispatchEvent(new Event(s,{bubbles:!0})),p.deletePrivate(o,g)},{once:!0}));return}let a=o.getAttribute(n),l=o.form&&o.form.getAttribute(n),h=a||l;if(!h||o.type==="number"&&o.validity&&o.validity.badInput)return;let d=a?o:o.form,f=t;t++;let{at:b,type:v}=p.private(o,"prev-iteration")||{};b===f-1&&s==="change"&&v==="input"||(p.putPrivate(o,"prev-iteration",{at:f,type:s}),this.debounce(o,r,s,()=>{this.withinOwners(d,g=>{p.putPrivate(o,re,!0),j.exec(r,"change",h,g,o,["push",{_target:r.target.name,dispatcher:d}])})}))},this.doofinderMount);this.on("reset",s=>{let r=s.target;p.resetForm(r);let n=Array.from(r.elements).find(o=>o.type==="reset");n&&window.requestAnimationFrame(()=>{n.dispatchEvent(new Event("input",{bubbles:!0,cancelable:!1}))})})}debounce(t,i,s,r){if(s==="blur"||s==="focusout")return r();let n=this.binding(Zr),o=this.binding(tn),a=this.defaults.debounce.toString(),l=this.defaults.throttle.toString();this.withinOwners(t,h=>{let d=()=>!h.isDestroyed()&&document.body.contains(t);p.debounce(t,i,n,a,o,l,d,()=>{r()})})}silenceEvents(t){this.silenced=!0,t(),this.silenced=!1}on(t,i,s=window){this.boundEventNames.add(t);let r=n=>{this.silenced||i(n)};s.addEventListener(t,r),this.unbindFunctions.push(function(){s.removeEventListener(t,r)})}jsQuerySelectorAll(t,i,s){let r=this.domCallbacks.jsQuerySelectorAll;return r?r(t,i,s):s()}},wn=class{constructor(){this.transitions=new Set,this.pendingOps=[]}reset(){this.transitions.forEach(t=>{clearTimeout(t),this.transitions.delete(t)}),this.flushPendingOps()}after(t){this.size()===0?t():this.pushPendingOp(t)}addTransition(t,i,s){i();let r=setTimeout(()=>{this.transitions.delete(r),s(),this.flushPendingOps()},t);this.transitions.add(r)}pushPendingOp(t){this.pendingOps.push(t)}size(){return this.transitions.size}flushPendingOps(){if(this.size()>0)return;let t=this.pendingOps.shift();t&&(t(),this.flushPendingOps())}};var Us=class{constructor(t){let{url:i,mount:s,hooks:r,params:n,mainHook:o,appName:a,disconnectCallback:l}=t,h={hooks:r,doofinderMount:s,params:n,dom:{onBeforeElUpdated(b,v){b instanceof HTMLDialogElement&&b.matches(":modal")&&b.hasAttribute("open")&&v.setAttribute("open","")}},metadata:{click:function(b,v){var C,D,R,x,F;let g=(v==null?void 0:v.getAttribute("dfd-click"))==="item-click",y=(F=(x=(R=(D=(C=t==null?void 0:t.hooks)==null?void 0:C.Layer)==null?void 0:D.tag)==null?void 0:R.state)==null?void 0:x.query)!=null?F:null;return P({keys:{altKey:b.altKey,shiftKey:b.shiftKey,ctrlKey:b.ctrlKey,metaKey:b.metaKey}},g&&{query:y})}},disconnectCallback:l};this.__mainHook=o,this.__socket=new Xe(i,_s,h),this.__appName=a;let d=this.__socket.restorePreviouslyActiveFocus.bind(this.__socket),f=this.__socket;this.__socket.restorePreviouslyActiveFocus=function(){var D,R;let b=f.prevActive,v=b instanceof HTMLInputElement||b instanceof HTMLTextAreaElement,g=navigator.maxTouchPoints>0,y=((R=(D=window.visualViewport)==null?void 0:D.height)!=null?R:window.innerHeight)/window.screen.height,C=g&&y<.9;(!v||!C)&&d()}}get liveSocket(){return this.__socket}get connected(){return this.__socket.isConnected()}get appName(){return this.__appName}enableDebug(){this.__socket.enableDebug()}disableDebug(){this.__socket.disableDebug()}setPreventReconnect(t=!1){var i;this.__socket.preventReconnect=t,t&&((i=this.__socket.reconnectTimer)==null||i.reset())}getHooksByName(t){if(this.connected){let i=this.__socket.doofinderMount,s=this.__socket.getViewByEl(i);return Array.from(i.querySelectorAll(`[dfd-hook="${t}"]`)).map(n=>s.getHook(n))}else return[]}connect(t){this.connected||this.__socket.connect(),Doofinder.Session.setLive(this.__appName),t()}disconnect(t){this.__socket.unbindTopLevelEvents(),this.__socket.destroyAllViews(),this.__socket.disconnect(t),this.__socket=null}pushEvent(t,i={},s=void 0){let[r]=this.getHooksByName(this.__mainHook);if(!r)throw new Error(`${this.__mainHook} hook is not ready!`);r.pushEvent(t,i,s)}};var ll="df-cookies-allowed",hl=window.localStorage,xd=window.sessionStorage,qe="functional",cl="analytical",Cn=[qe,cl];function dl(e){let t={};return Cn.forEach(i=>t[i]=e),t}function ul(){let e=JSON.parse(hl.getItem(ll)||"false");if(typeof e=="boolean")return dl(e);let t={};return Cn.forEach(i=>t[i]=e[i]===!0),t}function xi(e){return ul()[e]===!0}var We=class{constructor(t,i){this._bucket=t,this._store=i||window.localStorage}get data(){return JSON.parse(this._store.getItem(this._bucket))||{}}set data(t){!xi(qe)||this._store.setItem(this._bucket,JSON.stringify(t))}getItem(t){return this.data[t]}setItem(t,i){let s=this.data;s[t]=i,this.data=s}removeItem(t){let i=this.data;delete i[t],this.data=i}clear(){this.data={}}destroy(){this._store.removeItem(this._bucket)}popItem(t){let i=this.data,s=i[t];return delete i[t],this.data=i,s}};var fl="df-",An;function $s(e){return`${fl}${e.replace("_","-")}`}function Vs(e){let t=xi(qe),i=t?window.localStorage:window.sessionStorage;return t&&An===!1&&pl(e),An=t,i}function pl(e){let t=window.sessionStorage.getItem(e);!t||window.localStorage.setItem(e,t)}function Tn(e){let t=$s(e);return Vs(t).getItem(t)}function kn(e,t){let i=$s(e);Vs(i).setItem(i,String(t))}function xn(e){let t=$s(e);Vs(t).removeItem(t)}var js="dfd-animate",Bs="dfd-fixed-layout",Ut="hidden",Ke="ai_fullscreen",Pi="ai_fullscreen_conversational",Li="floating",ze="fullscreen",de="static",Pn=["AIFullscreen","AIFullscreenInitial","AIMobile","AIMobileInitial"];function Ii(e){let t=["left","top","right","bottom","width","height","scrollLeft","scrollTop","scrollWidth","scrollHeight"],i=t.reduce((r,n)=>(r[n]=0,r),{}),s=e;if(s===window)i=Z(P({},i),{width:s.outerWidth,height:s.outerHeight,clientWidth:s.innerWidth,clientHeight:s.innerHeight,scrollLeft:s.scrollX,scrollTop:s.scrollY,scrollWidth:document.scrollWidth,scrollHeight:document.scrollHeight});else{if(s===document)s=document.documentElement,i=Z(P({},i),{width:s.offsetWidth,height:s.offsetHeight});else if(s.getBoundingClientRect){let r=s.getBoundingClientRect();i=t.reduce((n,o)=>(n[o]=r[o],n),{})}i=Z(P({},i),{clientWidth:s.clientWidth,clientHeight:s.clientHeight,scrollLeft:s.scrollLeft,scrollTop:s.scrollTop,scrollWidth:s.scrollWidth,scrollHeight:s.scrollHeight})}return i}function Ln(e){let t=e;for(;t&&getComputedStyle(t).position!=="fixed";)t=t.offsetParent;return!!t}"use strict";var Xs=class{constructor(t,i={}){this.options=P({align:i.align,offsetX:0,offsetY:4,marginY:20,marginX:20,fillViewPortWidth:768},i),this.element=t}__origin__(t){let i=Ii(t),s=Ii(document),r=s.width<=this.options.fillViewPortWidth,n={width:i.width,top:i.top+i.height,left:i.left,fixed:Ln(t),align:function(){let o=Math.abs(i.left)*100/s.width,a=Math.abs(s.clientWidth-i.right)*100/s.width;switch(!0){case r:case Math.abs(o-a)<=15:return"center";case on-a&&(this.element.style.height=`${n-a}px`):this.element.style.height=`${n-a}px`}destroy(){["position","top","left","right","height","maxWidth","marginLeft"].forEach(t=>this.element.style[t]=null),this.options=null,this.element=null}};function Je(e,t=66,i=!1){let s;return function(...r){s?Date.now()-s>=t?(e(...r),s=Date.now()):i&&console.log("throttle: discard execution"):(e(...r),s=Date.now())}}var ue=class{constructor(t){this.mount=t,this._positionReference=null}__animate__(){return new Promise(t=>{setTimeout(()=>{this.mount.classList.add(js),t()},10)})}get positionReference(){return this._positionReference}show(){return I(this,null,function*(){let t=this.hidden();return t&&(this.mount.removeAttribute(Ut),yield this.__animate__()),t})}hide(){return I(this,null,function*(){let t=!this.hidden();return t&&(this.mount.setAttribute(Ut,""),this.mount.classList.remove(js),this.mount.innerHTML=""),t})}updatePosition(t){return I(this,null,function*(){this._positionReference=t.positionReference})}destroy(){this.mount=void 0}hidden(){return this.mount.hasAttribute(Ut)}};var qs=class extends ue{constructor(t,i={}){super(t);this.handleWindowChange=Je(this.handleWindowChange.bind(this)),this._position=new Xs(this.mount,i)}__addListeners__(){window.addEventListener("resize",this.handleWindowChange,{passive:!0})}__removeListeners__(){window.removeEventListener("resize",this.handleWindowChange)}get position(){return this._position}handleWindowChange(){this._position.update(this._positionReference)}show(){var t=i=>super[i];return I(this,null,function*(){let s=this.hidden();return s&&(this.mount.style.opacity="0",this.mount.removeAttribute(Ut)),this._position.update(this._positionReference),s&&(this.mount.setAttribute(Ut,""),this.mount.style.opacity="",yield t("show").call(this),this.__addListeners__()),s})}hide(){var t=i=>super[i];return I(this,null,function*(){let s=!this.hidden();return s&&(this.__removeListeners__(),yield t("hide").call(this)),s})}updatePosition(t){var i=s=>super[s];return I(this,null,function*(){i("updatePosition").call(this,t),setTimeout(()=>{var r;(r=this._position)==null||r.update(this._positionReference)},100)})}destroy(){this.__removeListeners__(),this._position.destroy(),this._position=null,super.destroy()}};var Ws=class extends ue{show(){var t=i=>super[i];return I(this,null,function*(){let s=this.hidden();return s&&(document.documentElement.classList.add(Bs),yield t("show").call(this)),s})}hide(){var t=i=>super[i];return I(this,null,function*(){let s=yield t("hide").call(this);return s&&document.documentElement.classList.remove(Bs),s})}};function Yt(e=8){let t="";for(;t.length{let n=0,o=null,a=t.interval||gl,l=t.times||ml;o=setInterval(function(){n++this.off(t,i)}once(t,i){if(this._checkReady())return this.el.addEventListener(t,i,{once:!0,passive:!0}),()=>this.off(t,i)}off(t,i){this._checkReady()&&this.el.removeEventListener(t,i)}emit(t,i){if(this._checkReady()){let s=new CustomEvent(t,{detail:i,bubbles:!1,cancelable:!1,composed:!1});this.el.dispatchEvent(s)}}teardown(){this._checkReady()&&(this.el=this.el.remove())}_checkReady(){if(this.el)return!0;throw new Error("tried to access a dead event bus!")}};var Gs="__DF_DEBUG_MODE__",In="true",Mi=window.sessionStorage;function Rn(){Mi.setItem(Gs,In)}function On(){Mi.removeItem(Gs)}function Hn(){return Mi.getItem(Gs)===In}function Qs(e){return Mi.getItem(e)||window[e]}function H(...e){Hn()&&console.log("[doofinder]",...e)}var Dn=function(e){let t=e.slice(0,4);return RegExp(`#${t}/(brand-categories|classic|classic-initial|embedded|ai-fullscreen|ai-fullscreen-conversational|ai-fullscreen-initial|fullscreen|fullscreen-brand-categories|fullscreen-initial|mobile|mobile-brand-categories|mobile-initial|ai-mobile|ai-mobile-initial)/`)},Mn=function(e){let t=e.slice(0,4);return RegExp(`#${t}/(category-pages|mobile-category-pages)/`)};"use strict";var $t=window.history,Ni=class{constructor({installationId:t,autoload:i,urlHash:s,layerType:r}){this._installationId=t,this._layerType=r,this._autoload=i?Object.freeze(i):null,this._urlHash=s,this._storage=new We(`${t}.data`,window.sessionStorage),this.__initialSetup__()}get hasAutoloadQueryParam(){return this.__getQueryFromAutoload__()!==null}get isTransitory(){return this._isTransitory}get page(){return this.__getPage__()}get query(){return this.__getQuery__()}get startPage(){var t;return(t=this._startPage)!=null?t:1}get targetItemId(){return this._targetItemId}get value(){return this._value}set targetItemId(t){this._targetItemId=t}saveTransitory(t){if(!this.__valid__(this._value)){H(`[state] [${this._layerType}] saveTransitory: not valid for `,this._value);return}H(`[state] [${this._layerType}] saveTransitory:`,this._value),this._storage.setItem(this.__getStateKey__(),{value:this.__simplify__(this._value),location:t})}update(t,i,s){if(!this.__hasChanged__(t,i,s))return H(`[state] [${this._layerType}] update not performed, the state has not changed.`,t,i,s),!1;this.__valid__(t)&&(H(`[state] [${this._layerType}] new state value: `,t),this._value=t),this._targetItemId=i,this._isTransitory=s;let r=window.location.origin+window.location.pathname+window.location.search;this._urlHash&&(r=r+this._value),H(`[state] [${this._layerType}] replaceState:`,r),$t.replaceState(this.__getNewStateObject__(),"",r)}__hasChanged__(t,i,s){return t!=this._value||i!=this._targetItemId||s!=this._isTransitory}__initialSetup__(){let t=this.__fromStorage__(),i=this.__fromHistory__()||t||this.__fromHash__()||this.__fromAutoload__()||"";i=i.match("^#([A-Za-z0-9-]+)/(embedded|classic)/$")?"":i,this._value=i,this._targetItemId=this.__getTargetItem__(),this._isTransitory=this.__isTransitory__(!!t),this._startPage=this.__getPage__(),t&&$t.replaceState(this.__getNewStateObject__(),"",window.location.href)}__fromAutoload__(){if(!this._autoload)return H(`[state] [${this._layerType}] __fromAutoload__ with autoload false - state:`,null),null;let t=this.__getQueryFromAutoload__(),i=t!=null?`#/${this._autoload.screen}/q=${t.trim()}`:null;return H(`[state] [${this._layerType}] __fromAutoload__ (query) state:`,i),i}__fromHash__(){let t=this.__validHash__(window.location.hash)?`#${window.location.hash.split("#",2)[1]}`:null;return H(`[state] [${this._layerType}] __fromHash__ state:`,t),t}__fromHistory__(){let t=null;return this.__validDoofinderStateInHistory__()&&(t=$t.state[this.__getStateKey__()].value),H(`[state] [${this._layerType}] __fromHistory__ state:`,t),t}__fromStorage__(){let t=this._storage.popItem(this.__getStateKey__());return!!t&&!window.location.href.includes(t.location)?(H(`[state] [${this._layerType}] __fromStorage__ discarded as it is from diferent location:`,t),null):(H(`[state] [${this._layerType}] __fromStorage__ state:`,t),!!t&&t.value)}__getNewStateObject__(){let t={[this.__getStateKey__()]:{value:this._value,transitory:this._isTransitory,targetItemId:this._targetItemId}};return H(`[state] [${this._layerType}] __getNewStateObject__:`,t),this.__validHistoryState__()?P(P({},$t.state),t):t}__getQuery__(){if(this._value){let t=this._value.split("/"),i=t[t.length-1];return Object.fromEntries(new URLSearchParams(i)).q}return""}__getPage__(){if(!this._value)return 1;let t=this._value.split("/"),i=t[t.length-1],{p:s}=Object.fromEntries(new URLSearchParams(i));return parseInt(s,10)||1}__getQueryFromAutoload__(){return this._autoload?new URLSearchParams(window.location.search).get(this._autoload.param):null}__getTargetItem__(){let t=null;return this.__validDoofinderStateInHistory__()&&(t=$t.state[this.__getStateKey__()].targetItemId),H(`[state] [${this._layerType}] __getTargetItem__:`,t),t}__getStateKey__(){return this._layerType=="category_pages"?Ni.CP_STATE_KEY:Ni.STATE_KEY}__isTransitory__(t){let i=t;return this.__validDoofinderStateInHistory__()&&(i=$t.state[this.__getStateKey__()].transitory),H(`[state] [${this._layerType}] __isTransitory__:`,i),i}__simplify__(t){var o;let s=new URL(window.location.origin+window.location.pathname+window.location.search+t).hash.split("/"),r=(o=s.pop())!=null?o:"",n=Object.fromEntries(r.split("&").map(a=>a.split("=")));return(n==null?void 0:n.q)?`${s.join("/")}/m=${n.m}&q=${n.q}`:""}__valid__(t){return this.__validHash__(t)||t===""}__validHistoryState__(){return typeof $t.state=="object"&&$t.state!==null}__validDoofinderStateInHistory__(){return this.__validHistoryState__()&&$t.state[this.__getStateKey__()]!=null}__validHash__(t){let i=this._layerType!=="category_pages"?Dn(this._installationId):Mn(this._installationId);return typeof t=="string"&&(i.test(t)||t.startsWith(`#/${this._installationId}/`))}},fe=Ni;ps(fe,"STATE_KEY","dfState"),ps(fe,"CP_STATE_KEY","dfCpState");var Zs=["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","Tab"];var tr="df:trigger:click",Ye="df:trigger:focus",Ge="df:trigger:input",er="df:trigger:submit";var pe=1;"use strict";var vl="[dfd-carousel-btn-left]",bl="[dfd-carousel-btn-right]",Nn="[dfd-carousel-content]",Fi="ltr",Fn={mounted(){this.btnLeftEl=this.el.querySelector(vl),this.btnRightEl=this.el.querySelector(bl),this.contentEl=this.el.querySelector(Nn),getComputedStyle(this.contentEl).direction==="rtl"&&(Fi="rtl"),this.getVisibleChildren=()=>{let e=this.contentEl.getBoundingClientRect();return Array.from(this.contentEl.children).filter(t=>{let i=t.getBoundingClientRect();return e.left<=i.left&&e.right>=i.right})},this.nextPage=()=>{let e=this.getVisibleChildren();if(e.length<=0)return;let t=e.slice(-1).pop(),i=t.nextElementSibling;if(!i)return;let s=this.contentEl.getBoundingClientRect(),r=t.getBoundingClientRect(),n=i.getBoundingClientRect(),o=r.width,a=i?n.x-r.x-r.width:0,l;Fi==="ltr"?l=this.contentEl.scrollLeft+(r.x-s.x):l=this.contentEl.scrollLeft-(r.x+s.x),this.contentEl.scroll({left:l+o+a/2,behavior:"smooth"})},this.previousPage=()=>{let e=this.getVisibleChildren();if(e.length<=0)return;let t=e[0],i=t.previousElementSibling;if(!i)return;let s=this.contentEl.getBoundingClientRect(),r=t.getBoundingClientRect(),n=i.getBoundingClientRect(),o=n.width-(s.x-n.x),a=i?r.x-n.x-n.width:0,l;Fi==="ltr"?l=this.contentEl.scrollLeft-s.width:l=this.contentEl.scrollLeft+s.width,this.contentEl.scroll({left:l+o+a/2,behavior:"smooth"})},this.btnLeftEl.addEventListener("click",this.previousPage),this.btnRightEl.addEventListener("click",this.nextPage),this.tag.dispatch("doofinder.carousel.load")},updated(){this.contentEl=this.el.querySelector(Nn),getComputedStyle(this.contentEl).direction==="rtl"&&(Fi="rtl"),this.tag.dispatch("doofinder.carousel.update")},destroyed(){this.btnLeftEl.removeEventListener("click",this.previousPage),this.btnRightEl.removeEventListener("click",this.nextPage)}};"use strict";var Un=".dfd-fashion-card__carousel-slide",$n=".dfd-fashion-card__chevron--prev",Vn=".dfd-fashion-card__chevron--next",ir="dfd-is-visible",yl="dfd-is-overlay-open",Ui="transform 0.25s ease";function jn(e){var n,o;let t=a=>{e.currentIndex=a,e.slides.forEach((l,h)=>{l.style.transform="",l.style.opacity="",l.classList.toggle(ir,h===a)})};e.onMouseEnter=()=>{e.slides.length>1&&e.currentIndex===0&&t(1)},e.onMouseLeave=()=>{e.slides.length>1&&t(0)},e.onPrev=a=>{a.preventDefault(),a.stopPropagation(),t((e.currentIndex-1+e.slides.length)%e.slides.length)},e.onNext=a=>{a.preventDefault(),a.stopPropagation(),t((e.currentIndex+1)%e.slides.length)},e.onTouchStart=a=>{var l;((l=e.card)==null?void 0:l.classList.contains(yl))||(e.touchStartX=a.touches[0].clientX,e.slideWidth=e.el.offsetWidth,e.slides.forEach(h=>{h.style.transition="none"}))},e.onTouchMove=a=>{if(e.touchStartX==null)return;let l=a.touches[0].clientX-e.touchStartX,h=(e.currentIndex+1)%e.slides.length,d=(e.currentIndex-1+e.slides.length)%e.slides.length;e.slides[e.currentIndex].style.transform=`translateX(${l}px)`,l<0?(e.slides[h].style.transform=`translateX(${e.slideWidth+l}px)`,e.slides[h].style.opacity="1"):(e.slides[d].style.transform=`translateX(${-e.slideWidth+l}px)`,e.slides[d].style.opacity="1")};let i=()=>{requestAnimationFrame(()=>{e.slides.forEach(a=>{a.style.transform="",a.style.opacity=""}),requestAnimationFrame(()=>{e.slides.forEach(a=>{a.style.transition=""})})})},s=a=>{let l=a<0?(e.currentIndex+1)%e.slides.length:(e.currentIndex-1+e.slides.length)%e.slides.length;e.slides[e.currentIndex].style.transition=Ui,e.slides[e.currentIndex].style.transform="translateX(0)",e.slides[l].style.transition=Ui,e.slides[l].style.transform=a<0?`translateX(${e.slideWidth}px)`:`translateX(${-e.slideWidth}px)`;let h=()=>{e.slides.forEach(d=>{d.style.transition="none",d.classList.contains(ir)||(d.style.opacity="0")}),i(),e.slides[e.currentIndex].removeEventListener("transitionend",h)};e.slides[e.currentIndex].addEventListener("transitionend",h)},r=(a,l)=>{let h=l<0?-1:1;e.slides[e.currentIndex].style.transition=Ui,e.slides[e.currentIndex].style.transform=`translateX(${h*e.slideWidth}px)`,e.slides[a].style.transition=Ui,e.slides[a].style.transform="translateX(0)";let d=()=>{e.currentIndex=a,e.slides.forEach((f,b)=>{let v=b===a;f.style.transition="none",v||(f.style.opacity="0"),f.classList.toggle(ir,v)}),i(),e.slides[a].removeEventListener("transitionend",d)};e.slides[a].addEventListener("transitionend",d)};e.onTouchEnd=a=>{if(e.touchStartX==null)return;let l=a.changedTouches[0].clientX-e.touchStartX,h=Math.abs(l)>e.slideWidth*.3?l<0?(e.currentIndex+1)%e.slides.length:(e.currentIndex-1+e.slides.length)%e.slides.length:e.currentIndex;h===e.currentIndex?s(l):r(h,l),e.touchStartX=null},(n=e.card)==null||n.addEventListener("mouseenter",e.onMouseEnter),(o=e.card)==null||o.addEventListener("mouseleave",e.onMouseLeave),e.el.addEventListener("touchstart",e.onTouchStart,{passive:!0}),e.el.addEventListener("touchmove",e.onTouchMove,{passive:!0}),e.el.addEventListener("touchend",e.onTouchEnd),Bn(e)}function Bn(e){let t=e.el.querySelector($n),i=e.el.querySelector(Vn);t==null||t.removeEventListener("click",e.onPrev),i==null||i.removeEventListener("click",e.onNext),t==null||t.addEventListener("click",e.onPrev),i==null||i.addEventListener("click",e.onNext)}var Xn={mounted(){this.slides=Array.from(this.el.querySelectorAll(Un)),this.card=this.el.closest(".dfd-fashion-card"),this.currentIndex=0,this.slides.length>1&&jn(this)},updated(){this.slides=Array.from(this.el.querySelectorAll(Un)),this.slides.length>1&&(this.currentIndex=0,this.slides.forEach(e=>{e.style.transition="none",e.style.transform="",e.style.opacity=""}),requestAnimationFrame(()=>{this.slides.forEach(e=>{e.style.transition=""})}),this.onPrev?Bn(this):jn(this))},destroyed(){var i,s;if(!this.onPrev)return;let e=this.el.querySelector($n),t=this.el.querySelector(Vn);(i=this.card)==null||i.removeEventListener("mouseenter",this.onMouseEnter),(s=this.card)==null||s.removeEventListener("mouseleave",this.onMouseLeave),e==null||e.removeEventListener("click",this.onPrev),t==null||t.removeEventListener("click",this.onNext),this.el.removeEventListener("touchstart",this.onTouchStart),this.el.removeEventListener("touchmove",this.onTouchMove),this.el.removeEventListener("touchend",this.onTouchEnd)}};"use strict";var $i="dfd-is-overlay-open",qn="dfd-fashion-card__backdrop",Sl=`.${$i}`,El=`.${qn}`,wl=".dfd-fashion-card__open-overlay-btn",Wn=".dfd-fashion-card__size-overlay",Kn="dfd-fashion-card__pricing--size-hover";function zn(e){let{formattedPrice:t,formattedSalePrice:i,discountLabel:s}=e.dataset,r=document.createDocumentFragment();if(i){let o=document.createElement("span");o.className="dfd-fashion-card__price dfd-fashion-card__price--sale",o.textContent=i,r.appendChild(o)}let n=document.createElement("span");if(n.className="dfd-fashion-card__price",n.textContent=t,r.appendChild(n),s){let o=document.createElement("div");o.className="dfd-fashion-card__discount",o.dataset.discount=s,o.textContent=s,r.appendChild(o)}return r}var sr="cubic-bezier(0.4, 0.0, 1, 1)",Jn="cubic-bezier(0.0, 0.0, 0.2, 1)",Qe=250,rr=200,Yn={mounted(){this.card=this.el.closest(".dfd-fashion-card"),this._backdrop=null,this._pricingEl=null,this._hoverPricingEl=null,this._activeBtn=null,this._setupHoverPricing=()=>{var s,r;let i=(s=this.card)==null?void 0:s.querySelector(`.dfd-fashion-card__pricing:not(.${Kn})`);!i||(this._pricingEl=i,(r=this._hoverPricingEl)==null||r.remove(),this._hoverPricingEl=document.createElement("div"),this._hoverPricingEl.className=`dfd-fashion-card__pricing ${Kn}`,this._hoverPricingEl.setAttribute("aria-hidden","true"),this._hoverPricingEl.style.display="none",i.insertAdjacentElement("afterend",this._hoverPricingEl))},this._restoreHoverPricing=()=>{var i;this._activeBtn=null,((i=this._hoverPricingEl)==null?void 0:i.isConnected)&&(this._hoverPricingEl.style.display="none",this._hoverPricingEl.replaceChildren(),this._hoverPricingEl.setAttribute("aria-hidden","true")),this._pricingEl&&(this._pricingEl.style.display="")},this._closeTimer=null,this._closingOverlay=!1,this.closeOverlay=()=>{var i;this.card.classList.remove($i),this._restoreHoverPricing(),this._backdrop&&(this._backdrop.style.transition=`opacity ${Qe}ms ${sr}`,this._backdrop.style.opacity="0"),clearTimeout(this._closeTimer),((i=history.state)==null?void 0:i.dfdOverlay)&&(this._closingOverlay=!0,history.back()),this._closeTimer=setTimeout(()=>{var s,r;(s=this._backdrop)==null||s.remove(),this._backdrop=null,document.body.style.overflow="",(r=this.el.closest(".dfd-layer"))==null||r.classList.remove("dfd-has-card-overlay")},Qe)},this.openOverlay=()=>{var n,o;clearTimeout(this._closeTimer),document.querySelectorAll(Sl).forEach(a=>a.classList.remove($i)),document.querySelectorAll(El).forEach(a=>a.remove()),document.querySelectorAll(".dfd-layer.dfd-has-card-overlay").forEach(a=>a.classList.remove("dfd-has-card-overlay"));let i=this.el.querySelector(Wn);i&&(i.style.transform="",i.style.transition="",i.style.visibility="");let s=this.card.closest(".dfd-card-live--fashion");s&&delete s.dataset.cartState,this.card.classList.add($i),(n=this.el.closest(".dfd-layer"))==null||n.classList.add("dfd-has-card-overlay"),this._backdrop=document.createElement("div"),this._backdrop.className=qn,((o=i==null?void 0:i.parentElement)!=null?o:this.el).appendChild(this._backdrop),this._backdrop.offsetHeight,this._backdrop.style.opacity="1",document.body.style.overflow="hidden",history.pushState({dfdOverlay:!0},""),this._backdrop.addEventListener("touchend",a=>{a.preventDefault(),this.closeOverlay()}),this._backdrop.addEventListener("click",this.closeOverlay)},this._onPopState=()=>{if(this._closingOverlay){this._closingOverlay=!1;return}this._backdrop&&this.closeOverlay()},window.addEventListener("popstate",this._onPopState);let e=this.el.querySelector(Wn);if(e){e.addEventListener("touchstart",a=>a.stopPropagation(),{passive:!0}),e.addEventListener("touchend",a=>a.stopPropagation()),e.addEventListener("click",a=>{a.target.closest(".dfd-fashion-card__size:not(.dfd-fashion-card__size--unavailable)")&&this.closeOverlay()});let i=e.querySelector(".dfd-fashion-card__sizes"),s=a=>{let l=120,h=.25;return a<=l?a:l+(a-l)*h},r=0,n=0,o=!1;e.addEventListener("touchstart",a=>{o=!!a.target.closest(".dfd-fashion-card__size-overlay-handle")||!i||i.scrollTop===0,o&&(r=a.changedTouches[0].clientY,n=Date.now(),e.style.transition="none")},{passive:!0}),e.addEventListener("touchmove",a=>{if(!o)return;let l=a.changedTouches[0].clientY-r;if(l>0&&(a.preventDefault(),a.stopPropagation(),e.style.transform=`translateY(${s(l)}px)`,this._backdrop)){let h=Math.min(l/e.offsetHeight,1);this._backdrop.style.transition="none",this._backdrop.style.opacity=String(1-h)}},{passive:!1}),e.addEventListener("touchend",a=>{if(a.stopPropagation(),!o)return;o=!1;let l=a.changedTouches[0].clientY-r,h=Math.max(Date.now()-n,1),d=l/h,f=e.offsetHeight*.3;l>=f||d>=.5?(this._backdrop&&(this._backdrop.style.transition=`opacity ${Qe}ms ${sr}`,this._backdrop.style.opacity="0"),e.style.transition=`transform ${Qe}ms ${sr}`,e.style.transform="translateY(100%)",setTimeout(()=>{this.closeOverlay()},Qe)):(this._backdrop&&(this._backdrop.style.transition=`opacity ${rr}ms ${Jn}`,this._backdrop.style.opacity="1"),e.style.transition=`transform ${rr}ms ${Jn}`,e.style.transform="translateY(0)",setTimeout(()=>{e.style.transition="",e.style.transform=""},rr))})}let t=this.el.querySelector(wl);t&&(t.addEventListener("touchstart",i=>i.stopPropagation(),{passive:!0}),t.addEventListener("touchend",i=>{i.stopPropagation(),i.preventDefault(),this.openOverlay()}),t.addEventListener("click",i=>{i.stopPropagation(),this.openOverlay()})),e&&(e.addEventListener("mouseover",i=>{var r;let s=i.target.closest(".dfd-fashion-card__size");!(s==null?void 0:s.dataset.formattedPrice)||s.classList.contains("dfd-fashion-card__size--unavailable")||s===this._activeBtn||(((r=this._hoverPricingEl)==null?void 0:r.isConnected)||this._setupHoverPricing(),!!this._hoverPricingEl&&(this._activeBtn=s,this._pricingEl.style.display="none",this._hoverPricingEl.replaceChildren(zn(s)),this._hoverPricingEl.style.display="",this._hoverPricingEl.removeAttribute("aria-hidden")))}),e.addEventListener("mouseleave",()=>{this._restoreHoverPricing()}))},updated(){var e;!this._pricingEl||(this._pricingEl.style.display="",this._setupHoverPricing(),((e=this._activeBtn)==null?void 0:e.isConnected)&&this._hoverPricingEl&&(this._pricingEl.style.display="none",this._hoverPricingEl.replaceChildren(zn(this._activeBtn)),this._hoverPricingEl.style.display="",this._hoverPricingEl.removeAttribute("aria-hidden")))},destroyed(){var e;window.removeEventListener("popstate",this._onPopState),this.closeOverlay(),(e=this._hoverPricingEl)==null||e.remove()}};var Vi=240;function Cl(e){return!!e.type.match(/image\/.*/)}function Gn(e){return I(this,null,function*(){if(!Cl(e))throw"invalid image, can't search";let t=yield Qn(e),i=yield Al(t);return yield Qn(i)})}function Qn(e){return new Promise(function(t,i){let s=new FileReader;s.onload=function(){t(s.result)},s.onerror=function(){i(s.error)},s.readAsDataURL(e)})}function Al(e){return new Promise(function(t,i){let s=new Image;s.onload=function(){let r=document.createElement("canvas");r.width=Vi,r.height=Vi,r.getContext("2d").drawImage(s,0,0,Vi,Vi),r.toBlob(function(n){t(n)},"image/jpeg")},s.onerror=function(r){i("resize image error")},s.src=e})}var Zn={mounted(){this.search=e=>I(this,null,function*(){this.el.dataset.status="loading";try{let t=yield Gn(e);this.pushEvent("search",{search:{image:t}},i=>{delete this.el.dataset.status})}catch(t){delete this.el.dataset.status}}),this.el.addEventListener("change",e=>this.search(e.target.files[0]))}};function nr(e){setTimeout(()=>{e.focus()},0)}var Tl=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function kl(e){return[...e.querySelectorAll(Tl)].filter(t=>!t.closest("[hidden]")&&t.offsetParent!==null)}function to(e,t){if(e.key!=="Tab")return;let i=kl(t);if(i.length===0)return;let s=i[0],r=i[i.length-1];e.shiftKey?document.activeElement===s&&(e.preventDefault(),r.focus()):document.activeElement===r&&(e.preventDefault(),s.focus())}function eo(){return"virtualKeyboard"in navigator}"use strict";var io={mounted(){this.isDesktop=()=>this.tag._device==="desktop",this.setFocus=()=>{nr(this.el);let e=this.el.value.length;this.el.setSelectionRange(e,e)},this.unsetFocus=(e=0)=>{setTimeout(()=>{var t;(t=document.activeElement)==null||t.blur()},e)},this.search=e=>{let t=this.el.dataset.dfdAction||"search";this.pushEvent(t,{search:{query:e}})},this.autocompleteEl=()=>{var e;return(e=this.el.parentElement)==null?void 0:e.querySelector(".dfd-searchbox-autocomplete")},this.syncAutocompleteVisibility=()=>{let e=this.autocompleteEl();if(!e)return;let t=this.el.value.trim()==="",i=(this.el.getAttribute("dfd-value-suggestion")||"").trim();e.hidden=t||i===""},this.handleEvent("click-suggestion",e=>{var t;this.el.value=(t=e==null?void 0:e.search)==null?void 0:t.query,this.setFocus()}),this.handleEvent("set-input-focus",()=>this.setFocus()),this.handleEvent("unset-input-focus",()=>this.unsetFocus()),this.el.addEventListener("input",()=>{this.search(this.el.value)}),this.el.addEventListener("keydown",e=>{if(e.key==="Enter"&&e.preventDefault(),this.charLimitReached(e))return;let t=this.el.getAttribute("dfd-value-suggestion");e.key==="Tab"&&t&&t!==this.el.value&&(this.el.value=t,nr(this.el),this.search(t))}),this.el.addEventListener("keyup",e=>{if(e.key!=="Enter")return;let t=this.el.closest("form");if(t){let i=new Event("submit",{bubbles:!0,cancelable:!0});t.dispatchEvent(i),this.isDesktop()&&eo()&&this.unsetFocus(10)}}),this.charLimitReached=function(e){return e.type!=="keydown"||this.el.value.length<50||Zs.includes(e.key)?!1:(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!0)},this.syncAutocompleteVisibility()},updated(){var e;(e=this.syncAutocompleteVisibility)==null||e.call(this)}};"use strict";var or=class{constructor({dfid:t,variants:i,quantity:s,quantityPinned:r,quantityStep:n}){if(!t)throw new Error("dfid is mandatory for AddToCartState");if(!i)throw new Error("variants is mandatory for AddToCartState");this.dfid=t,this.variants=i,this.showQuantity=s,this.quantityPinned=r,this.quantityStep=n,this.item=null,this.variantsItems=[],this.filters={},this._amountSelected=r?n:0}get nextEmptyVariant(){return this.variants.find(t=>!this.filters[t])}get amountSelected(){return this.showQuantity?this._amountSelected:1}get status(){return Object.keys(this.filters).lengthe!==""),quantity:this.el.dataset.quantity.toLowerCase()==="true",quantityPinned:this.el.dataset.quantityPinned.toLowerCase()==="true",quantityStep:parseInt(this.el.dataset.quantityStep||1)}),this.el.addEventListener("click",e=>{if(!e.target.closest("[data-role]"))return;let t=Object.keys(this.functions).find(i=>e.target.closest("[data-role]").dataset.role.match(i));t&&(this.functions[t](e.target.closest("[data-role]"))(),e.preventDefault(),e.stopPropagation())}),this.el.addEventListener("input",e=>{this.addToCartState.amountSelected=parseInt(e.target.value||0),this._updateQuantityButtons()}),this.functions={add_to_cart:e=>()=>{if(this.addToCartState.status==="variants"){let t=this.addToCartState.nextEmptyVariant,i=this.el.querySelector(`[data-role=open_selector][data-variant="${t}"]`);this.functions.open_selector(i)()}else if(this.addToCartState.status==="quantity")this.addToCartState.increaseQuantity(),this._updateQuantityInput(),this._openQuantitySelector();else if(this.addToCartState.status==="ready"){let t=this.addToCartState.amountSelected,i=this.addToCartState.filters;this.addToCart(t,i)}},increase_quantity:e=>()=>{this.addToCartState.increaseQuantity(),this._updateQuantityInput(),this._updateQuantityButtons()},decrease_quantity:e=>()=>{this.addToCartState.decreaseQuantity(),this._updateQuantityInput(),this._updateQuantityButtons()},delete_quantity:e=>()=>{this.addToCartState.quantityPinned||(this.addToCartState.amountSelected=0,this._updateQuantityInput(),this._closeQuantitySelector())},open_selector:e=>()=>{let t=e.dataset.variant;this.pushEventTo(`#${this.el.dataset.liveComponentId}`,"load-variants",{},i=>{this.addToCartState.variantsItems=i.variants,this._openSelector(t)})},select_variant:e=>()=>{let t=e.closest("[data-role=selector]").dataset.variant,i=e.dataset.val;this.pushEventTo(`#${this.el.dataset.liveComponentId}`,"select-variant",{variant:t,value:i},s=>{this.addToCartState.filters=s.filters,this._closeSelector(t),this._updateVariantValue(t,i)})},close_selector:e=>()=>{let t=e.closest("[data-role=selector]").dataset.variant;this._closeSelector(t)}},this.addToCart=(e,t)=>{let i={amount:e,filters:t};this._startAddToCart(),this.pushEventTo(`#${this.el.dataset.liveComponentId}`,"get-item",i,s=>{let r=s.item;this.addToCartState.filters=t,this.addToCartState.amountSelected=e,r.statusPromise=new At({resolveTimeout:3e3,rejectTimeout:5e3}),r.statusPromise.then(this._finishAddToCart,this._finishAddToCart),document.dispatchEvent(new CustomEvent(xl,{detail:r}))})},this._closeSelector=e=>{this._execJS(`[data-role=selector][data-variant="${e}"]`,"hide")},this._openSelector=e=>{this._execJS(`[data-role=selector][data-variant="${e}"]`,"show")},this._updateVariantValue=(e,t)=>{this._execJS(`[data-role=open_selector][data-variant="${e}"] input`,"set_attr",["value",t])},this._openQuantitySelector=()=>{this._execJS(null,"set_attr",["data-status","quantity"]),this._execJS("[data-role=decrease_quantity]","hide"),this._execJS("[data-role=delete_quantity]","show")},this._closeQuantitySelector=()=>{this._execJS(null,"set_attr",["data-status","initial"]),this._execJS("[data-role=decrease_quantity]","show"),this._execJS("[data-role=delete_quantity]","hide")},this._updateQuantityButtons=()=>{this.addToCartState.amountSelected<=this.addToCartState.quantityStep?(this._execJS("[data-role=decrease_quantity]","hide"),this._execJS("[data-role=delete_quantity]","show")):(this._execJS("[data-role=decrease_quantity]","show"),this._execJS("[data-role=delete_quantity]","hide"))},this._updateQuantityInput=()=>{let e=this.el.querySelector("[data-role=amount_selected]");this._execJS("[data-role=amount_selected]","set_attr",["value",this.addToCartState.amountSelected]),e&&(e.value=this.addToCartState.amountSelected)},this._execJS=(e,t,i)=>{let s=e?this.el.querySelector(e):this.el;if(s==null)return;let r;t==="set_attr"?r=[[t,{to:null,attr:[i[0],i[1]]}]]:t==="remove_class"||t==="add_class"?r=[[t,{to:null,time:200,names:[i],transition:[[],[],[]]}]]:r=[[t,{to:null}]],this.liveSocket.execJS(s,JSON.stringify(r))},this.addToCartState.quantityPinned&&(this._execJS("[data-role=decrease_quantity]","hide"),this._execJS(null,"set_attr",["data-quantity-pinned","true"]),this._updateQuantityInput()),this._startAddToCart=()=>{this._execJS(".dfd-cart-check-button[data-role=add_to_cart]","add_class","dfd-btn-loading"),this._execJS(".dfd-cart-add-button [data-role=add_to_cart]","add_class","dfd-btn-loading")},this._finishAddToCart=e=>{let t={amount:this.addToCartState.amountSelected,filters:this.addToCartState.filters};this.pushEventTo(`#${this.el.dataset.liveComponentId}`,"add-to-cart",t,()=>{this._execJS(".dfd-cart-check-button[data-role=add_to_cart]","remove_class","dfd-btn-loading"),this._execJS(".dfd-cart-add-button [data-role=add_to_cart]","remove_class","dfd-btn-loading"),this._execJS(".dfd-cart-check-button[data-role=add_to_cart]","add_class","dfd-btn-done"),this._execJS(".dfd-cart-add-button [data-role=add_to_cart]","add_class","dfd-btn-done"),this._execJS(null,"set_attr",["data-status","initial"]),this.addToCartState.reset(),this._updateQuantityInput(),setTimeout(()=>{this._execJS(".dfd-cart-check-button[data-role=add_to_cart]","remove_class","dfd-btn-done"),this._execJS(".dfd-cart-add-button [data-role=add_to_cart]","remove_class","dfd-btn-done")},500),typeof e=="function"&&e()})}}};function me(e){return`${M}:${e}`}"use strict";var ji="doofinder.cart.add.click",Pl="doofinder.cart.add",Bi="doofinder.cart.hide.price",Xi="doofinder.cart.display.price",ar="dfd-btn-loading",ro="dfd-btn-done",no="dfd-btn-error";function oo(e){e.addToCartResolveTimeout=3e3,e.addToCartRejectTimeout=5e3,e.addToCartButtonFeedback=function(i,s){let r=Ll.bind(null,i,s),n=Ol.bind(null,i,i.innerHTML),o=Il.bind(null,i,n),a=Rl.bind(null,i,n);r().then(o,a)},e.handleCartAddClick=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target,r=new At({resolveTimeout:e.addToCartResolveTimeout,rejectTimeout:e.addToCartRejectTimeout});r.then(n=>{e.pushEvent("add-to-cart",{item:i.detail.item,dfid:i.detail.dfid},()=>{typeof n=="function"&&n()}),e.pushEvent("close-add-to-cart-button",{item:i.detail.item,dfid:i.detail.dfid})},n=>{typeof n=="function"&&n(),e.pushEvent("close-add-to-cart-button",{item:i.detail.item,dfid:i.detail.dfid})}),setTimeout(()=>e.tag.dispatch(Pl,Z(P({},i.detail.item),{statusPromise:r})),1e3),e.addToCartButtonFeedback&&e.addToCartButtonFeedback(s,r)},e.handleHidePrice=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target;s.closest(".dfd-card-row").querySelector(".dfd-card-pricing").style.display="none"},e.handleDisplayPrice=i=>{let s=i.detail.target?document.getElementById(i.detail.target.id):i.target;s.closest(".dfd-card-row").querySelector(".dfd-card-pricing").style.display="flex"};let t=!!e.tag&&!!e.tag.dom?e.tag.dom.mount:e.tag.mount;t.addEventListener(ji,e.handleCartAddClick),t.addEventListener(me(ji),e.handleCartAddClick),t.addEventListener(Bi,e.handleHidePrice),t.addEventListener(me(Bi),e.handleHidePrice),t.addEventListener(Xi,e.handleDisplayPrice),t.addEventListener(me(Xi),e.handleDisplayPrice)}function ao(e){let t=!!e.tag&&!!e.tag.dom?e.tag.dom.mount:e.tag.mount;t.removeEventListener(ji,e.handleCartAddClick),t.removeEventListener(me(ji),e.handleCartAddClick),t.removeEventListener(Bi,e.handleHidePrice),t.removeEventListener(me(Bi),e.handleHidePrice),t.removeEventListener(Xi,e.handleDisplayPrice),t.removeEventListener(me(Xi),e.handleDisplayPrice)}function Ll(e,t){return e.setAttribute("disabled",""),e.setAttribute("dfd-update","ignore"),e.innerHTML="",e.classList.add(ar),t}function Il(e,t){e.classList.remove(ar),e.classList.add(ro),setTimeout(t,1e3)}function Rl(e,t){e.classList.remove(ar),e.classList.add(no),setTimeout(t,2e3)}function Ol(e,t){e.classList.remove(ro),e.classList.remove(no),e.innerHTML=t,e.removeAttribute("dfd-update"),e.removeAttribute("disabled")}function lo(e,t){return typeof e!="undefined"?e:t}var Pe=class{constructor(t,i,s={}){let{threshold:r}=s;this.handleIntersection=this.handleIntersection.bind(this),this._callback=i,this._io=new IntersectionObserver(this.handleIntersection,{root:t,threshold:lo(r,0)})}observe(t){this._io.disconnect(),t&&this._io.observe(t),H("[ScrollObserver][observe]",t)}unobserve(){this._io.disconnect(),H("[ScrollObserver][unobserve]")}handleIntersection([t]){H("[ScrollObserver][intersection detected] target:",t.target),this._callback(t)}};"use strict";var ho={mounted(){this.close=()=>this.pushEvent("close-layer"),this.handleEvent("close",()=>{this.tag.disconnect()}),this.handleEvent("change-state",({state:e})=>{this.tag.updateState({value:e})}),this.handleEvent("disconnect",e=>{e.errors.forEach(t=>console.error("[Doofinder] error:",t)),Doofinder.Session.removeLive("layer"),this.tag.destroy()}),this.handleEvent("load",e=>{this.tag.onLoad(e),this.tag.dispatch("doofinder.layer.load",{display_type:e.display_type}),this.pushEvent("ready")}),this.handleEvent("click-suggestion",e=>I(this,null,function*(){var t;this.tag.trigger.updateQuery((t=e==null?void 0:e.search)==null?void 0:t.query)})),this.handleEvent("set-trigger-focus",()=>I(this,null,function*(){this.tag.trigger.focus()})),this.handleEvent("search",e=>{this.tag.dispatch("doofinder.layer.search",e)}),this.handleEvent("item-click",e=>{this.tag.dispatch("doofinder.layer.itemClick",e)}),this.handleEvent("update-latest-searches",({entries:e})=>{this.tag.updateLatestSearches(e)}),this.handleEvent("check-activity",()=>{this.tag.updateLastActivity()}),this.handleEvent("chat-store",e=>{e.action==="set"?Object.entries(e.data).forEach(([t,i])=>{kn(t,i)}):e.action==="delete"&&Object.keys(e.data).forEach(t=>{xn(t)})}),this.el.addEventListener("contextmenu",e=>{let t=e.target.closest('[dfd-click="item-click"]');if(t){let i=t.getAttribute("dfd-value-link"),s=t.getAttribute("dfd-value-dfid");this.pushEvent("item-click",{link:i,dfid:s},()=>{this.debug(`item-click sent for ${s} to ${i}`)})}}),this.el.addEventListener("error",({target:e})=>{if(e.tagName!=="IMG")return;let t=e.closest('[data-dfd-role="card-thumbnail"]');setTimeout(()=>{t==null||t.parentElement.setAttribute("dfd-update","ignore"),t==null||t.classList.add("dfd-card-thumbnail-404")},1)},!0),this.applyOperationBySelector=function(e,t){if(e.startsWith("#")){let i=document.getElementById(e);t(i)}else this.el.querySelectorAll(e).forEach(i=>{t(i)})},this.handleEvent("dom:add-class",({target:e,newClass:t})=>{this.applyOperationBySelector(e.selector,i=>i==null?void 0:i.classList.add(t))}),this.handleEvent("dom:remove-class",({target:e,oldClass:t})=>{this.applyOperationBySelector(e.selector,i=>i==null?void 0:i.classList.remove(t))}),this.handleEvent("dom:add-attribute",({target:e,name:t,value:i})=>{this.applyOperationBySelector(e.selector,s=>s==null?void 0:s.setAttribute(t,i))}),this.handleEvent("dom:remove-attribute",({target:e,name:t})=>{this.applyOperationBySelector(e.selector,i=>i==null?void 0:i.removeAttribute(t))}),this.handleEvent("redirection:update",({redirection:e})=>{this.tag.trigger.redirection=e}),this.el.classList.contains("dfd-fashion-theme")&&(this._onFashionScroll=e=>{e.target.classList.contains("dfd-content")&&this.el.classList.toggle("dfd-is-scrolled",e.target.scrollTop>0)},this.el.addEventListener("scroll",this._onFashionScroll,!0)),oo(this),this.handleEvent("fashion-card.add-to-cart",e=>{let t=this.el.querySelector(`[data-product-id="${e.id}"]`);t&&(t.dataset.cartState="loading");let i=new At({resolveTimeout:3e3,rejectTimeout:5e3});i.then(()=>{if(t){let s=t.querySelector(".dfd-fashion-card");(s==null?void 0:s.classList.contains("dfd-is-overlay-open"))||(t.dataset.cartState="success",setTimeout(()=>delete t.dataset.cartState,2e3))}this.pushEvent("add-to-cart",{item:e})},()=>{t&&delete t.dataset.cartState}),document.dispatchEvent(new CustomEvent("doofinder.cart.add",{detail:Z(P({},e),{statusPromise:i})}))})},updated(){this.tag.dispatch("doofinder.layer.update")},destroyed(){this.el.removeEventListener("scroll",this._onFashionScroll,!0),ao(this)}},co={mounted(){this.handleEvent("disconnect",e=>{e.errors.forEach(t=>console.error("[Doofinder] error:",t)),Doofinder.Session.removeLive("layer"),this.tag.destroy()})}},uo={mounted(){this._preventPaginationLinkDefault=e=>{var i,s;((s=(i=e.target).closest)==null?void 0:s.call(i,'a[dfd-click="prev-page"], a[dfd-click="next-page"], a[dfd-click="go-to-page"]'))&&e.preventDefault()},this.el.addEventListener("click",this._preventPaginationLinkDefault,!0),this.handleEvent("scroll-to-top",()=>{window.scrollTo({top:0,behavior:"smooth"})})},destroyed(){this.el.removeEventListener("click",this._preventPaginationLinkDefault,!0)}},fo={mounted(){po(this.el)},updated(){po(this.el)}};function po(e){let t=e.querySelector("[dfd-update=stream]"),i=t?t.querySelectorAll('[dfd-click="item-click"]:not([data-dfd-item-position])'):[];if(i.length===0)return;let s=null;if(t){let r=t.querySelectorAll('[id*="card-link-"][data-dfd-item-position]');s=r.length>0?r[r.length-1]:null}i.forEach(r=>{s?r.setAttribute("dfd-value-position",parseInt(s.getAttribute("dfd-value-position"))+1):r.setAttribute("dfd-value-position",1),s=r})}var mo={mounted(){this.layer=this.el.closest(".dfd-layer"),this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.layerObserver=new Pe(null,e=>{e.isIntersecting?(e.boundingClientRect.top<0&&this.pushEvent("change-back-to-top-visibility",{visible:!0}),this.pushEvent("change-filters-visibility",{visible:!0})):(this.pushEvent("change-back-to-top-visibility",{visible:!1}),this.pushEvent("change-filters-visibility",{visible:!1}))}),this.layerObserver.observe(this.layer)},destroyed(){var e;(e=this.layerObserver)==null||e.unobserve()}};var go=Object.freeze({Linear:function(e){return e},EaseInQuad:function(e){return e*e},EaseOutQuad:function(e){return e*(2-e)},EaseInOutQuad:function(e){return e<.5?2*e*e:-1+(4-2*e)*e},EaseInCubic:function(e){return e*e*e},EaseOutCubic:function(e){return--e*e*e+1},EaseInOutCubic:function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},EaseInQuart:function(e){return e*e*e*e},EaseOutQuart:function(e){return 1- --e*e*e*e},EaseInOutQuart:function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},EaseInQuint:function(e){return e*e*e*e*e},EaseOutQuint:function(e){return 1+--e*e*e*e*e},EaseInOutQuint:function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e}});function _o(e,t,i,s,r=go.EaseInQuint){let n=Date.now(),o=t[e];return new Promise((a,l)=>{function h(){let d=Date.now(),f=Math.min(1,(d-n)/s),b=r(f);t[e]=o+b*(i-o),f<1?requestAnimationFrame(h):a()}o===i?a():requestAnimationFrame(h)})}var vo=_o.bind(null,"scrollTop"),Gu=_o.bind(null,"scrollLeft");function Hl(e){let t=e.scrollHeight>e.clientHeight,s=window.getComputedStyle(e).overflowY.indexOf("hidden")!==-1;return t&&!s}function qi(e){return!e||e===document.documentElement?document.documentElement:Hl(e)?e:qi(e.parentNode)}var bo='[data-dfd-role~="scroll-sentinel"]',Dl='[data-dfd-role~="scroll-top-sentinel"]',Ml="div.dfd-card";function Wi(e,t,i){i?e.scrollTop=t:vo(e,t,250)}function Nl(e){var s,r;let t=((s=document.querySelector(Ml))==null?void 0:s.offsetHeight)||0,i=((r=document.querySelector(bo))==null?void 0:r.offsetHeight)||0;return e.scrollHeight-i-t*2.6}function Fl(e,t){e.pushEvent("change-back-to-top-visibility",{visible:t})}function Ul(e,t,i){e.debug(`[handle] "back-to-top", id: ${t}, fast: ${i}`),e.scrollTarget()==="window"?window.scrollTo(0,0):(!t||t===e.el.id)&&Wi(qi(e.el),0,i)}function lr(e){var t,i;(((t=e.tag.display)==null?void 0:t.type)!="static"||((i=e.tag.connection)==null?void 0:i.appName)==="quiz")&&(e.loadMoreObserver=new Pe(e.el,({target:s,isIntersecting:r})=>{var h,d,f;let n=((h=e.tag.connection)==null?void 0:h.appName)!="quiz"?".dfd-results-grid":"#dfd-quiz-results-container",o=(d=e.el.querySelector(n))==null?void 0:d.children.length;if(!r||!o)return;let a={index:s.dataset.index},l=(f=e.tag.state)==null?void 0:f.query;typeof l=="string"&&l.trim()!==""&&(a.query=l),e.debug('[push] "load-more", params:',a),e.pushEvent("load-more",a)}))}function yo(e){var t;(t=e.loadMoreObserver)==null||t.unobserve(),e._observerReconnectTimeout&&clearTimeout(e._observerReconnectTimeout),e._observerReconnectTimeout=setTimeout(()=>{var i;(i=e.loadMoreObserver)==null||i.observe(e.sentinel()),e._observerReconnectTimeout=null},500)}var hr={mounted(){var t,i;this.sentinel=()=>this.el.querySelector(bo),this.scrollTopSentinel=()=>this.el.querySelector(Dl),this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.scrollTopVisible=!1,this._saveScrollPosition=Je(()=>{let s=this.el.scrollTop,r=history.state||{};history.replaceState(Z(P({},r),{dfScrollTop:s}),"")},200),this.el.addEventListener("scroll",this._saveScrollPosition),lr(this);let e=((t=this.tag.display)==null?void 0:t.type)!="static"?this.el:null;this.scrollTopObserver=new Pe(e,s=>{let r=!s.isIntersecting&&s.boundingClientRect.top<0;this.scrollTopVisible!==r&&(this.scrollTopVisible=r,Fl(this,r))}),this.handleEvent("search",s=>{var a,l;this.debug('[handle] "search", params:',s);let{index:r,page:n}=s,o=this.sentinel();!$l(s.filter)&&n===1&&r===(o==null?void 0:o.dataset.index)&&Wi(this.el,0,!0),this.loadMoreObserver||lr(this),!this.tag.state||this.tag.state.page===1?yo(this):(a=this.loadMoreObserver)==null||a.observe(this.sentinel()),(l=this.scrollTopObserver)==null||l.observe(this.scrollTopSentinel())}),this.handleEvent("back-to-top",({id:s,fast:r})=>{Ul(this,s,r)}),this.handleEvent("change-current-index",()=>{var s;(s=this.loadMoreObserver)==null||s.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel()),Wi(this.el,0,!0)}),(i=this.loadMoreObserver)==null||i.observe(this.sentinel()),this.scrollTopObserver.observe(this.scrollTopSentinel())},updated(){var e;!this.loadMoreObserver&&lr(this),!this.tag.state||this.tag.state.page===1?yo(this):(e=this.loadMoreObserver)==null||e.observe(this.sentinel())},destroyed(){var e,t;this.el.removeEventListener("scroll",this._saveScrollPosition),(e=this.loadMoreObserver)==null||e.unobserve(),this.loadMoreObserver=null,(t=this.scrollTopObserver)==null||t.unobserve(),this.scrollTopObserver=null}},cr={mounted(){this.hideVirtualKeyboard=Je(()=>{let e=document.querySelector("input:focus, textarea:focus");e?(this.debug("[hideVirtualKeyboard][blur] input:",e),e.blur()):this.debug("[hideVirtualKeyboard][noop]")},100),this.debug("[observe][touchstart] hideVirtualKeyboard()"),this.el.addEventListener("touchstart",this.hideVirtualKeyboard)},destroyed(){this.debug("[unobserve][touchstart] hideVirtualKeyboard()"),this.el.removeEventListener("touchstart",this.hideVirtualKeyboard)}},dr={mounted(){this.scrollTarget=()=>this.el.dataset.dfdScrollTarget,this.transientTargetCard=()=>this.el.querySelector(`[dfd-value-dfid="${this.tag.state.targetItemId}"]`),this.handleEvent("update-scroll",e=>{setTimeout((()=>{var i;let t=this.transientTargetCard();if(this.debug('[handle] "update-scroll"',"params:",e,"card:",t),this.tag.targetItemId=null,t!==null)t.scrollIntoView({behavior:"smooth",block:"nearest"});else if(e.scroll_end){let s=(i=history.state)==null?void 0:i.dfScrollTop,r=qi(this.el);s>0?r.scrollTop=s:Wi(r,Nl(this.el),!1)}this.pushEvent("scroll-updated",{})}).bind(this),1e3)})}};function $l(e){return!!e&&Object.keys(e).length>0}"use strict";var So={mounted(){let e=this.el.closest("dialog");e&&window.getComputedStyle(e).transitionProperty.includes("height")?e==null||e.addEventListener("close",()=>{setTimeout(()=>{this.pushEventTo(this.el,"close-modal",{})},300)}):e==null||e.addEventListener("close",()=>{this.pushEventTo(this.el,"close-modal",{})}),this.handleEvent("open-modal",()=>{if(e==null?void 0:e.open){this.el.scrollTo({top:0,behavior:"smooth"});return}e==null||e.showModal(),this.el.scrollTo({top:0})})}};function Ki(e,t,i,s){return new Intl.NumberFormat(e,{style:"currency",maximumFractionDigits:parseInt(i,10),numberingSystem:s,currency:t})}function zi(e,t,i){return new Intl.NumberFormat(e,{maximumFractionDigits:parseInt(t,10),numberingSystem:i})}var ur=class{constructor(t,i,s,r,n){this.template=t,this.symbol=i,this.thousand=s,this.decimal=r,this.precision=n}format(t){let i=t<0,s=Math.pow(10,this.precision),r=(Math.round(t*s)/s).toFixed(this.precision),n=`${parseInt(Math.abs(r||0).toFixed(this.precision),10)}`,o=n.length>3?n.length%3:0,a=r.split(".")[1],l=[];return o>0&&l.push(`${n.substring(0,o)}${this.thousand}`),l.push(n.substring(o).replace(/(\d{3})(?=\d)/g,"$1"+this.thousand)),this.precision>0&&parseInt(a,10)>0&&l.push(`${this.decimal}${a}`),l=this.template.replace(/%s/g,this.symbol).replace(/%v/g,l.join("")),i&&(l=`-${l}`),l}};"use strict";var Gt;(function(e){e.Range="range",e.Steps="steps",e.Positions="positions",e.Count="count",e.Values="values"})(Gt||(Gt={}));var pt;(function(e){e[e.None=-1]="None",e[e.NoValue=0]="NoValue",e[e.LargeValue=1]="LargeValue",e[e.SmallValue=2]="SmallValue"})(pt||(pt={}));function Vl(e){return Ji(e)&&typeof e.from=="function"}function Ji(e){return typeof e=="object"&&typeof e.to=="function"}function Eo(e){e.parentElement.removeChild(e)}function fr(e){return e!=null}function wo(e){e.preventDefault()}function jl(e){return e.filter(function(t){return this[t]?!1:this[t]=!0},{})}function Bl(e,t){return Math.round(e/t)*t}function Xl(e,t){var i=e.getBoundingClientRect(),s=e.ownerDocument,r=s.documentElement,n=To(s);return/webkit.*Chrome.*Mobile/i.test(navigator.userAgent)&&(n.x=0),t?i.top+n.y-r.clientTop:i.left+n.x-r.clientLeft}function Pt(e){return typeof e=="number"&&!isNaN(e)&&isFinite(e)}function Co(e,t,i){i>0&&(ut(e,t),setTimeout(function(){Gi(e,t)},i))}function Ao(e){return Math.max(Math.min(e,100),0)}function Yi(e){return Array.isArray(e)?e:[e]}function ql(e){e=String(e);var t=e.split(".");return t.length>1?t[1].length:0}function ut(e,t){e.classList&&!/\s/.test(t)?e.classList.add(t):e.className+=" "+t}function Gi(e,t){e.classList&&!/\s/.test(t)?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," ")}function Wl(e,t){return e.classList?e.classList.contains(t):new RegExp("\\b"+t+"\\b").test(e.className)}function To(e){var t=window.pageXOffset!==void 0,i=(e.compatMode||"")==="CSS1Compat",s=t?window.pageXOffset:i?e.documentElement.scrollLeft:e.body.scrollLeft,r=t?window.pageYOffset:i?e.documentElement.scrollTop:e.body.scrollTop;return{x:s,y:r}}function Kl(){return window.navigator.pointerEnabled?{start:"pointerdown",move:"pointermove",end:"pointerup"}:window.navigator.msPointerEnabled?{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}:{start:"mousedown touchstart",move:"mousemove touchmove",end:"mouseup touchend"}}function zl(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("test",null,t)}catch(i){}return e}function Jl(){return window.CSS&&CSS.supports&&CSS.supports("touch-action","none")}function pr(e,t){return 100/(t-e)}function mr(e,t,i){return t*100/(e[i+1]-e[i])}function Yl(e,t){return mr(e,e[0]<0?t+Math.abs(e[0]):t-e[0],0)}function Gl(e,t){return t*(e[1]-e[0])/100+e[0]}function Ze(e,t){for(var i=1;e>=t[i];)i+=1;return i}function Ql(e,t,i){if(i>=e.slice(-1)[0])return 100;var s=Ze(i,e),r=e[s-1],n=e[s],o=t[s-1],a=t[s];return o+Yl([r,n],i)/pr(o,a)}function Zl(e,t,i){if(i>=100)return e.slice(-1)[0];var s=Ze(i,t),r=e[s-1],n=e[s],o=t[s-1],a=t[s];return Gl([r,n],(i-o)*pr(o,a))}function th(e,t,i,s){if(s===100)return s;var r=Ze(s,e),n=e[r-1],o=e[r];return i?s-n>(o-n)/2?o:n:t[r-1]?e[r-1]+Bl(s-e[r-1],t[r-1]):s}var ko=function(){function e(t,i,s){this.xPct=[],this.xVal=[],this.xSteps=[],this.xNumSteps=[],this.xHighestCompleteStep=[],this.xSteps=[s||!1],this.xNumSteps=[!1],this.snap=i;var r,n=[];for(Object.keys(t).forEach(function(o){n.push([Yi(t[o]),o])}),n.sort(function(o,a){return o[0][0]-a[0][0]}),r=0;rthis.xPct[r+1];)r++;else t===this.xPct[this.xPct.length-1]&&(r=this.xPct.length-2);!s&&t===this.xPct[r+1]&&r++,i===null&&(i=[]);var n,o=1,a=i[r],l=0,h=0,d=0,f=0;for(s?n=(t-this.xPct[r])/(this.xPct[r+1]-this.xPct[r]):n=(this.xPct[r+1]-t)/(this.xPct[r+1]-this.xPct[r]);a>0;)l=this.xPct[r+1+f]-this.xPct[r+f],i[r+f]*o+100-n*100>100?(h=l*n,o=(a-100*n)/i[r+f],n=1):(h=i[r+f]*l/100*o,o=0),s?(d=d-h,this.xPct.length+f>=1&&f--):(d=d+h,this.xPct.length-f>=1&&f++),a=i[r+f]*o;return t+d},e.prototype.toStepping=function(t){return t=Ql(this.xVal,this.xPct,t),t},e.prototype.fromStepping=function(t){return Zl(this.xVal,this.xPct,t)},e.prototype.getStep=function(t){return t=th(this.xPct,this.xSteps,this.snap,t),t},e.prototype.getDefaultStep=function(t,i,s){var r=Ze(t,this.xPct);return(t===100||i&&t===this.xPct[r-1])&&(r=Math.max(r-1,1)),(this.xVal[r]-this.xVal[r-1])/s},e.prototype.getNearbySteps=function(t){var i=Ze(t,this.xPct);return{stepBefore:{startValue:this.xVal[i-2],step:this.xNumSteps[i-2],highestStep:this.xHighestCompleteStep[i-2]},thisStep:{startValue:this.xVal[i-1],step:this.xNumSteps[i-1],highestStep:this.xHighestCompleteStep[i-1]},stepAfter:{startValue:this.xVal[i],step:this.xNumSteps[i],highestStep:this.xHighestCompleteStep[i]}}},e.prototype.countStepDecimals=function(){var t=this.xNumSteps.map(ql);return Math.max.apply(null,t)},e.prototype.hasNoSize=function(){return this.xVal[0]===this.xVal[this.xVal.length-1]},e.prototype.convert=function(t){return this.getStep(this.toStepping(t))},e.prototype.handleEntryPoint=function(t,i){var s;if(t==="min"?s=0:t==="max"?s=100:s=parseFloat(t),!Pt(s)||!Pt(i[0]))throw new Error("noUiSlider: 'range' value isn't numeric.");this.xPct.push(s),this.xVal.push(i[0]);var r=Number(i[1]);s?this.xSteps.push(isNaN(r)?!1:r):isNaN(r)||(this.xSteps[0]=r),this.xHighestCompleteStep.push(0)},e.prototype.handleStepPoint=function(t,i){if(!!i){if(this.xVal[t]===this.xVal[t+1]){this.xSteps[t]=this.xHighestCompleteStep[t]=this.xVal[t];return}this.xSteps[t]=mr([this.xVal[t],this.xVal[t+1]],i,0)/pr(this.xPct[t],this.xPct[t+1]);var s=(this.xVal[t+1]-this.xVal[t])/this.xNumSteps[t],r=Math.ceil(Number(s.toFixed(3))-1),n=this.xVal[t]+this.xNumSteps[t]*r;this.xHighestCompleteStep[t]=n}},e}(),xo={to:function(e){return e===void 0?"":e.toFixed(2)},from:Number},Po={target:"target",base:"base",origin:"origin",handle:"handle",handleLower:"handle-lower",handleUpper:"handle-upper",touchArea:"touch-area",horizontal:"horizontal",vertical:"vertical",background:"background",connect:"connect",connects:"connects",ltr:"ltr",rtl:"rtl",textDirectionLtr:"txt-dir-ltr",textDirectionRtl:"txt-dir-rtl",draggable:"draggable",drag:"state-drag",tap:"state-tap",active:"active",tooltip:"tooltip",pips:"pips",pipsHorizontal:"pips-horizontal",pipsVertical:"pips-vertical",marker:"marker",markerHorizontal:"marker-horizontal",markerVertical:"marker-vertical",markerNormal:"marker-normal",markerLarge:"marker-large",markerSub:"marker-sub",value:"value",valueHorizontal:"value-horizontal",valueVertical:"value-vertical",valueNormal:"value-normal",valueLarge:"value-large",valueSub:"value-sub"},Qt={tooltips:".__tooltips",aria:".__aria"};function eh(e,t){if(!Pt(t))throw new Error("noUiSlider: 'step' is not numeric.");e.singleStep=t}function ih(e,t){if(!Pt(t))throw new Error("noUiSlider: 'keyboardPageMultiplier' is not numeric.");e.keyboardPageMultiplier=t}function sh(e,t){if(!Pt(t))throw new Error("noUiSlider: 'keyboardMultiplier' is not numeric.");e.keyboardMultiplier=t}function rh(e,t){if(!Pt(t))throw new Error("noUiSlider: 'keyboardDefaultStep' is not numeric.");e.keyboardDefaultStep=t}function nh(e,t){if(typeof t!="object"||Array.isArray(t))throw new Error("noUiSlider: 'range' is not an object.");if(t.min===void 0||t.max===void 0)throw new Error("noUiSlider: Missing 'min' or 'max' in 'range'.");e.spectrum=new ko(t,e.snap||!1,e.singleStep)}function oh(e,t){if(t=Yi(t),!Array.isArray(t)||!t.length)throw new Error("noUiSlider: 'start' option is incorrect.");e.handles=t.length,e.start=t}function ah(e,t){if(typeof t!="boolean")throw new Error("noUiSlider: 'snap' option must be a boolean.");e.snap=t}function lh(e,t){if(typeof t!="boolean")throw new Error("noUiSlider: 'animate' option must be a boolean.");e.animate=t}function hh(e,t){if(typeof t!="number")throw new Error("noUiSlider: 'animationDuration' option must be a number.");e.animationDuration=t}function Lo(e,t){var i=[!1],s;if(t==="lower"?t=[!0,!1]:t==="upper"&&(t=[!1,!0]),t===!0||t===!1){for(s=1;s1)throw new Error("noUiSlider: 'padding' option must not exceed 100% of the range.")}}function fh(e,t){switch(t){case"ltr":e.dir=0;break;case"rtl":e.dir=1;break;default:throw new Error("noUiSlider: 'direction' option was not recognized.")}}function ph(e,t){if(typeof t!="string")throw new Error("noUiSlider: 'behaviour' must be a string containing options.");var i=t.indexOf("tap")>=0,s=t.indexOf("drag")>=0,r=t.indexOf("fixed")>=0,n=t.indexOf("snap")>=0,o=t.indexOf("hover")>=0,a=t.indexOf("unconstrained")>=0,l=t.indexOf("invert-connects")>=0,h=t.indexOf("drag-all")>=0,d=t.indexOf("smooth-steps")>=0;if(r){if(e.handles!==2)throw new Error("noUiSlider: 'fixed' behaviour must be used with 2 handles");Io(e,e.start[1]-e.start[0])}if(l&&e.handles!==2)throw new Error("noUiSlider: 'invert-connects' behaviour must be used with 2 handles");if(a&&(e.margin||e.limit))throw new Error("noUiSlider: 'unconstrained' behaviour cannot be used with margin or limit");e.events={tap:i||n,drag:s,dragAll:h,smoothSteps:d,fixed:r,snap:n,hover:o,unconstrained:a,invertConnects:l}}function mh(e,t){if(t!==!1)if(t===!0||Ji(t)){e.tooltips=[];for(var i=0;i= 2) required for mode 'count'.");for(var u=c.values-1,m=100/u,S=[];u--;)S[u]=u*m;return S.push(100),N(S,c.stepped)}return c.mode===Gt.Positions?N(c.values,c.stepped):c.mode===Gt.Values?c.stepped?c.values.map(function(E){return v.fromStepping(v.getStep(v.toStepping(E)))}):c.values:[]}function N(c,u){return c.map(function(m){return v.fromStepping(u?v.getStep(m):m)})}function $(c){function u(q,G){return Number((q+G).toFixed(7))}var m=Y(c),S={},E=v.xVal[0],w=v.xVal[v.xVal.length-1],k=!1,A=!1,X=0;return m=jl(m.slice().sort(function(q,G){return q-G})),m[0]!==E&&(m.unshift(E),k=!0),m[m.length-1]!==w&&(m.push(w),A=!0),m.forEach(function(q,G){var Q,V,st,ht=q,nt=m[G+1],ot,hs,cs,ds,Hr,us,Dr,Mr=c.mode===Gt.Steps;for(Mr&&(Q=v.xNumSteps[G]),Q||(Q=nt-ht),nt===void 0&&(nt=ht),Q=Math.max(Q,1e-7),V=ht;V<=nt;V=u(V,Q)){for(ot=v.toStepping(V),hs=ot-X,Hr=hs/(c.density||1),us=Math.round(Hr),Dr=hs/us,st=1;st<=us;st+=1)cs=X+st*Dr,S[cs.toFixed(5)]=[v.fromStepping(cs),0];ds=m.indexOf(V)>-1?pt.LargeValue:Mr?pt.SmallValue:pt.NoValue,!G&&k&&V!==nt&&(ds=0),V===nt&&A||(S[ot.toFixed(5)]=[V,ds]),X=ot}}),S}function jt(c,u,m){var S,E,w=F.createElement("div"),k=(S={},S[pt.None]="",S[pt.NoValue]=t.cssClasses.valueNormal,S[pt.LargeValue]=t.cssClasses.valueLarge,S[pt.SmallValue]=t.cssClasses.valueSub,S),A=(E={},E[pt.None]="",E[pt.NoValue]=t.cssClasses.markerNormal,E[pt.LargeValue]=t.cssClasses.markerLarge,E[pt.SmallValue]=t.cssClasses.markerSub,E),X=[t.cssClasses.valueHorizontal,t.cssClasses.valueVertical],q=[t.cssClasses.markerHorizontal,t.cssClasses.markerVertical];ut(w,t.cssClasses.pips),ut(w,t.ort===0?t.cssClasses.pipsHorizontal:t.cssClasses.pipsVertical);function G(V,st){var ht=st===t.cssClasses.value,nt=ht?X:q,ot=ht?k:A;return st+" "+nt[t.ort]+" "+ot[V]}function Q(V,st,ht){if(ht=u?u(st,ht):ht,ht!==pt.None){var nt=T(w,!1);nt.className=G(ht,t.cssClasses.marker),nt.style[t.style]=V+"%",ht>pt.NoValue&&(nt=T(w,!1),nt.className=G(ht,t.cssClasses.value),nt.setAttribute("data-value",String(st)),nt.style[t.style]=V+"%",nt.innerHTML=String(m.to(st)))}}return Object.keys(c).forEach(function(V){Q(V,c[V][0],c[V][1])}),w}function vt(){f&&(Eo(f),f=null)}function It(c){vt();var u=$(c),m=c.filter,S=c.format||{to:function(E){return String(Math.round(E))}};return f=o.appendChild(jt(u,m,S)),f}function te(){var c=a.getBoundingClientRect(),u="offset"+["Width","Height"][t.ort];return t.ort===0?c.width||a[u]:c.height||a[u]}function lt(c,u,m,S){var E=function(k){var A=_e(k,S.pageOffset,S.target||u);if(!A||Dt()&&!S.doNotReject||Wl(o,t.cssClasses.tap)&&!S.doNotReject||c===s.start&&A.buttons!==void 0&&A.buttons>1||S.hover&&A.buttons)return!1;n||A.preventDefault(),A.calcPoint=A.points[t.ort],m(A,S)},w=[];return c.split(" ").forEach(function(k){u.addEventListener(k,E,n?{passive:!0}:!1),w.push([k,E])}),w}function _e(c,u,m){var S=c.type.indexOf("touch")===0,E=c.type.indexOf("mouse")===0,w=c.type.indexOf("pointer")===0,k=0,A=0;if(c.type.indexOf("MSPointer")===0&&(w=!0),c.type==="mousedown"&&!c.buttons&&!c.touches)return!1;if(S){var X=function(Q){var V=Q.target;return V===m||m.contains(V)||c.composed&&c.composedPath().shift()===m};if(c.type==="touchstart"){var q=Array.prototype.filter.call(c.touches,X);if(q.length>1)return!1;k=q[0].pageX,A=q[0].pageY}else{var G=Array.prototype.find.call(c.changedTouches,X);if(!G)return!1;k=G.pageX,A=G.pageY}}return u=u||To(F),(E||w)&&(k=c.clientX+u.x,A=c.clientY+u.y),c.pageOffset=u,c.points=[k,A],c.cursor=E||w,c}function Ct(c){var u=c-Xl(a,t.ort),m=u*100/te();return m=Ao(m),t.dir?100-m:m}function Le(c){var u=100,m=!1;return h.forEach(function(S,E){if(!Mt(E)){var w=y[E],k=Math.abs(w-c),A=k===100&&u===100,X=kw;(X||q||A)&&(m=E,u=k)}}),m}function ii(c,u){c.type==="mouseout"&&c.target.nodeName==="HTML"&&c.relatedTarget===null&&rs(c,u)}function _a(c,u){if(navigator.appVersion.indexOf("MSIE 9")===-1&&c.buttons===0&&u.buttonsProperty!==0)return rs(c,u);var m=(t.dir?-1:1)*(c.calcPoint-u.startCalcPoint),S=m*100/u.baseSize;xr(m>0,S,u.locations,u.handleNumbers,u.connect)}function rs(c,u){u.handle&&(Gi(u.handle,t.cssClasses.active),D-=1),u.listeners.forEach(function(m){B.removeEventListener(m[0],m[1])}),D===0&&(Gi(o,t.cssClasses.drag),ls(),c.cursor&&(U.style.cursor="",U.removeEventListener("selectstart",wo))),t.events.smoothSteps&&(u.handleNumbers.forEach(function(m){ee(m,y[m],!0,!0,!1,!1)}),u.handleNumbers.forEach(function(m){tt("update",m)})),u.handleNumbers.forEach(function(m){tt("change",m),tt("set",m),tt("end",m)})}function ns(c,u){if(!u.handleNumbers.some(Mt)){var m;if(u.handleNumbers.length===1){var S=h[u.handleNumbers[0]];m=S.children[0],D+=1,ut(m,t.cssClasses.active)}c.stopPropagation();var E=[],w=lt(s.move,B,_a,{target:c.target,handle:m,connect:u.connect,listeners:E,startCalcPoint:c.calcPoint,baseSize:te(),pageOffset:c.pageOffset,handleNumbers:u.handleNumbers,buttonsProperty:c.buttons,locations:y.slice()}),k=lt(s.end,B,rs,{target:c.target,handle:m,listeners:E,doNotReject:!0,handleNumbers:u.handleNumbers}),A=lt("mouseout",B,ii,{target:c.target,handle:m,listeners:E,doNotReject:!0,handleNumbers:u.handleNumbers});E.push.apply(E,w.concat(k,A)),c.cursor&&(U.style.cursor=getComputedStyle(c.target).cursor,h.length>1&&ut(o,t.cssClasses.drag),U.addEventListener("selectstart",wo,!1)),u.handleNumbers.forEach(function(X){tt("start",X)})}}function va(c){c.stopPropagation();var u=Ct(c.calcPoint),m=Le(u);m!==!1&&(t.events.snap||Co(o,t.cssClasses.tap,t.animationDuration),ee(m,u,!0,!0),ls(),tt("slide",m,!0),tt("update",m,!0),t.events.snap?ns(c,{handleNumbers:[m]}):(tt("change",m,!0),tt("set",m,!0)))}function ba(c){var u=Ct(c.calcPoint),m=v.getStep(u),S=v.fromStepping(m);Object.keys(R).forEach(function(E){E.split(".")[0]==="hover"&&R[E].forEach(function(w){w.call(ni,S)})})}function ya(c,u){if(Dt()||Mt(u))return!1;var m=["Left","Right"],S=["Down","Up"],E=["PageDown","PageUp"],w=["Home","End"];t.dir&&!t.ort?m.reverse():t.ort&&!t.dir&&(S.reverse(),E.reverse());var k=c.key.replace("Arrow",""),A=k===E[0],X=k===E[1],q=k===S[0]||k===m[0]||A,G=k===S[1]||k===m[1]||X,Q=k===w[0],V=k===w[1];if(!q&&!G&&!Q&&!V)return!0;c.preventDefault();var st;if(G||q){var ht=q?0:1,nt=Rr(u),ot=nt[ht];if(ot===null)return!1;ot===!1&&(ot=v.getDefaultStep(y[u],q,t.keyboardDefaultStep)),X||A?ot*=t.keyboardPageMultiplier:ot*=t.keyboardMultiplier,ot=Math.max(ot,1e-7),ot=(q?-1:1)*ot,st=g[u]+ot}else V?st=t.spectrum.xVal[t.spectrum.xVal.length-1]:st=t.spectrum.xVal[0];return ee(u,v.toStepping(st),!0,!0),tt("slide",u),tt("update",u),tt("change",u),tt("set",u),!1}function kr(c){c.fixed||h.forEach(function(u,m){lt(s.start,u.children[0],ns,{handleNumbers:[m]})}),c.tap&<(s.start,a,va,{}),c.hover&<(s.move,a,ba,{hover:!0}),c.drag&&d.forEach(function(u,m){if(!(u===!1||m===0||m===d.length-1)){var S=h[m-1],E=h[m],w=[u],k=[S,E],A=[m-1,m];ut(u,t.cssClasses.draggable),c.fixed&&(w.push(S.children[0]),w.push(E.children[0])),c.dragAll&&(k=h,A=C),w.forEach(function(X){lt(s.start,X,ns,{handles:k,handleNumbers:A,connect:u})})}})}function os(c,u){R[c]=R[c]||[],R[c].push(u),c.split(".")[0]==="update"&&h.forEach(function(m,S){tt("update",S)})}function Sa(c){return c===Qt.aria||c===Qt.tooltips}function Ie(c){var u=c&&c.split(".")[0],m=u?c.substring(u.length):c;Object.keys(R).forEach(function(S){var E=S.split(".")[0],w=S.substring(E.length);(!u||u===E)&&(!m||m===w)&&(!Sa(w)||m===w)&&delete R[S]})}function tt(c,u,m){Object.keys(R).forEach(function(S){var E=S.split(".")[0];c===E&&R[S].forEach(function(w){w.call(ni,g.map(t.format.to),u,g.slice(),m||!1,y.slice(),ni)})})}function si(c,u,m,S,E,w,k){var A;return h.length>1&&!t.events.unconstrained&&(S&&u>0&&(A=v.getAbsoluteDistance(c[u-1],t.margin,!1),m=Math.max(m,A)),E&&u1&&t.limit&&(S&&u>0&&(A=v.getAbsoluteDistance(c[u-1],t.limit,!1),m=Math.min(m,A)),E&&u1?S.forEach(function(Q,V){var st=si(w,Q,w[Q]+u,X[V],q[V],!1,A);st===!1?u=0:(u=st-w[Q],w[Q]=st)}):X=q=[!0];var G=!1;S.forEach(function(Q,V){G=ee(Q,m[Q]+u,X[V],q[V],!1,A)||G}),G&&(S.forEach(function(Q){tt("update",Q),tt("slide",Q)}),E!=null&&tt("drag",k))}function Pr(c,u){return t.dir?100-c-u:c}function Ea(c,u){y[c]=u,g[c]=v.fromStepping(u);var m=Pr(u,0)-_,S="translate("+as(m+"%","0")+")";if(h[c].style[t.transformRule]=S,t.events.invertConnects&&y.length>1){var E=y.every(function(w,k,A){return k===0||w>=A[k-1]});if(x!==!E){xa();return}}Re(c),Re(c+1),x&&(Re(c-1),Re(c+2))}function ls(){C.forEach(function(c){var u=y[c]>50?-1:1,m=3+(h.length+u*c);h[c].style.zIndex=String(m)})}function ee(c,u,m,S,E,w){return E||(u=si(y,c,u,m,S,!1,w)),u===!1?!1:(Ea(c,u),!0)}function Re(c){if(!!d[c]){var u=y.slice();x&&u.sort(function(A,X){return A-X});var m=0,S=100;c!==0&&(m=u[c-1]),c!==d.length-1&&(S=u[c]);var E=S-m,w="translate("+as(Pr(m,E)+"%","0")+")",k="scale("+as(E/100,"1")+")";d[c].style[t.transformRule]=w+" "+k}}function Lr(c,u){return c===null||c===!1||c===void 0||(typeof c=="number"&&(c=String(c)),c=t.format.from(c),c!==!1&&(c=v.toStepping(c)),c===!1||isNaN(c))?y[u]:c}function ri(c,u,m){var S=Yi(c),E=y[0]===void 0;u=u===void 0?!0:u,t.animate&&!E&&Co(o,t.cssClasses.tap,t.animationDuration),C.forEach(function(A){ee(A,Lr(S[A],A),!0,!1,m)});var w=C.length===1?0:1;if(E&&v.hasNoSize()&&(m=!0,y[0]=0,C.length>1)){var k=100/(C.length-1);C.forEach(function(A){y[A]=A*k})}for(;w=0&&cm.stepAfter.startValue&&(E=m.stepAfter.startValue-S),S>m.thisStep.startValue?w=m.thisStep.step:m.stepBefore.step===!1?w=!1:w=S-m.stepBefore.highestStep,u===100?E=null:u===0&&(w=null);var k=v.countStepDecimals();return E!==null&&E!==!1&&(E=Number(E.toFixed(k))),w!==null&&w!==!1&&(w=Number(w.toFixed(k))),[w,E]}function Ta(){return C.map(Rr)}function ka(c,u){var m=Ir(),S=["margin","limit","padding","range","animate","snap","step","format","pips","tooltips","connect"];S.forEach(function(w){c[w]!==void 0&&(i[w]=c[w])});var E=Ro(i);S.forEach(function(w){c[w]!==void 0&&(t[w]=E[w])}),v=E.spectrum,t.margin=E.margin,t.limit=E.limit,t.padding=E.padding,t.pips?It(t.pips):vt(),t.tooltips?L():Lt(),y=[],ri(fr(c.start)?c.start:m,u),c.connect&&Or()}function Or(){for(;l.firstChild;)l.removeChild(l.firstChild);for(var c=0;c<=t.handles;c++)d[c]=it(l,t.connect[c]),Re(c);kr({drag:t.events.drag,fixed:!0})}function xa(){x=!x,Lo(t,t.connect.map(function(c){return!c})),Or()}function Pa(){a=mt(o),K(t.connect,a),kr(t.events),ri(t.start),t.pips&&It(t.pips),t.tooltips&&L(),O()}Pa();var ni={destroy:Aa,steps:Ta,on:os,off:Ie,get:Ir,set:ri,setHandle:Ca,reset:wa,disable:Vt,enable:Zt,__moveHandles:function(c,u,m){xr(c,u,y,m)},options:i,updateOptions:ka,target:o,removePips:vt,removeTooltips:Lt,getPositions:function(){return y.slice()},getTooltips:function(){return b},getOrigins:function(){return h},pips:It};return ni}function Ch(e,t){if(!e||!e.nodeName)throw new Error("noUiSlider: create requires a single element, got: "+e);if(e.noUiSlider)throw new Error("noUiSlider: Slider was already initialized.");var i=Ro(t),s=wh(e,i,t);return e.noUiSlider=s,s}var Oo={__spectrum:ko,cssClasses:Po,create:Ch};function Ho(e){return e.filter((t,i)=>e.indexOf(t)===i)}function Do(e){let t={};return{to(i){let s=e.format(i);return t[s]=i,s},from(i){return t[i]}}}function gr(e,t){let{min:i,max:s,from:r,to:n}=e;return i=parseFloat(i),s=parseFloat(s),i===s&&s++,r=parseFloat(r)||i,n=parseFloat(n)||s,{range:{min:i,max:s},start:[t.to(r),t.to(n)]}}function Mo(e,t,i,s={}){let r=e.dataset.facetLabel||"";return e&&e.noUiSlider&&e.noUiSlider.destroy(),Oo.create(e,P({cssPrefix:"dfd-slider-",orientation:"horizontal",direction:s.rtl?"rtl":"ltr",tooltips:!0,padding:0,connect:!0,animate:!0,step:1,keyboardSupport:!0,format:t,handleAttributes:[{"aria-label":`Minimum ${r}`},{"aria-label":`Maximum ${r}`}],pips:{mode:"count",values:3,density:6,stepped:!0,format:t}},i))}function No(e,t,i){let s=getComputedStyle(e).direction==="rtl",r=e.noUiSlider.options.direction==="rtl",n=e.noUiSlider.options.orientation==="vertical",a=e.noUiSlider.getTooltips().map(h=>h.cloneNode(!0)),l=e.noUiSlider.getOrigins();a.forEach(function(h,d){h&&l[d].appendChild(h)}),e.noUiSlider.on("update",function(h,d,f,b,v){let g=[[]],y=[[]],C=[[]],D=0;a[0]&&(g[0][0]=0,y[0][0]=v[0],C[0][0]=h[0]);for(let R=1;Rt)&&(D++,g[D]=[],C[D]=[],y[D]=[]),a[R]&&(g[D].push(R),C[D].push(h[R]),y[D].push(v[R]));g.forEach(function(R,x){let F=R.length;for(let B=0;Btypeof r=="string"?new ur(r,o,a,s,parseInt(n,10)):i?Ki(t,i,parseInt(n,10),y):zi(t,parseInt(l,10),y))();this.format=Do(D),this.slider=Mo(this.el,this.format,gr({min:h,max:d,from:f,to:b},this.format),{rtl:C});let R=(B=this.el.closest(".dfd-facet-content"))==null?void 0:B.querySelector(".dfd-fashion-range-labels"),x=R?Array.from(R.querySelectorAll("span")):null,F=(U,_)=>{if(!x||!_)return;let[T,et]=x;T.textContent=this.format.to(Math.floor(this.format.from(U[0]))),et.textContent=this.format.to(Math.ceil(this.format.from(U[1])))};x&&F(this.slider.get(),this.slider.getPositions()),this.isUpdating=!1,this.slider.on("update",function(U,_,T,et,it){if(this.isUpdating)return;let[K,mt]=U,z=Math.floor(this.format.from(K)),Dt=Math.ceil(this.format.from(mt)),Mt=parseFloat(this.el.dataset.actualMin),Vt=parseFloat(this.el.dataset.actualMax),Zt=!1,Lt=K,L=mt;z>Vt&&(Lt=this.format.to(Vt),Zt=!0),Dt{this.isUpdating=!1},0)),F(U,it)}.bind(this)),this.slider.on("change",U=>{let[_,T]=U,it={index:this.el.dataset.index,range:{[e]:{from:this.format.from(_),to:this.format.from(T)}}};v?this.pushEventTo(v,"slide",it):this.pushEvent("slide",it)}),g||No(this.el,25," - ")},updated(){let{min:e,max:t,from:i,to:s}=this.el.dataset;this.slider.updateOptions(gr({min:e,max:t,from:i,to:s},this.format))},destroyed(){var e;(e=this.el.noUiSlider)==null||e.destroy()}};"use strict";var Uo={mounted(){let e=0,t=0;this.el.addEventListener("touchstart",i=>{e=i.changedTouches[0].screenY},!1),this.el.addEventListener("touchend",i=>{t=i.changedTouches[0].screenY,!(t<=e)&&(this.el.closest("dialog:modal#dfd-similar-results-modal")?this.pushEventTo(this.el,this.el.dataset.action,{index:""}):this.pushEvent(this.el.dataset.action,{index:""}))},!1)}};"use strict";var _r=class{constructor(t){this._el=t,this._prevHeight=null,this._prevViewKey=null,this._heightAnimation=null,this._dragging=!1,this._gestureFinalHeight=null,this._gestureFinalViewKey=null,this._gestureAt=0,this._pendingViewChangeTimer=null,this._pendingExpectedAction=null}dragStart(){this._dragging=!0}dragMove(t,i,s,r,n){let o=i;n&&o<0&&(o=Math.max(o,-24)),Ah(t,o,s,r),t&&(this._gestureFinalHeight=t.getBoundingClientRect().height,this._gestureAt=performance.now())}endDrag(){this._dragging=!1}dragCancel(t,i=500){this._dragging=!1,$o(t,i)}shouldDispatch(t){if(!t)return!1;let i=ge(this._el);return!vr(t,i)}actionDispatched(t,i){this._dragging=!1,t&&(this._gestureFinalHeight=t.getBoundingClientRect().height,this._gestureFinalViewKey=ge(this._el),this._gestureAt=performance.now()),this._pendingViewChangeTimer&&clearTimeout(this._pendingViewChangeTimer),this._pendingExpectedAction=i,this._pendingViewChangeTimer=setTimeout(()=>{this._pendingViewChangeTimer=null;let s=ge(this._el);vr(i,s)||$o(t,250),this._pendingExpectedAction=null},450)}beforeUpdate(){this._cancelAnimation(),this._gestureAt&&performance.now()-this._gestureAt<250&&Number.isFinite(this._gestureFinalHeight)?(this._prevHeight=this._gestureFinalHeight,this._prevViewKey=this._gestureFinalViewKey||ge(this._el)):(this._prevHeight=this._el.getBoundingClientRect().height,this._prevViewKey=ge(this._el)),this._gestureFinalHeight=null,this._gestureFinalViewKey=null,this._gestureAt=0}updated(){let t=this._prevHeight;this._prevHeight=null;let i=this._prevViewKey;if(this._prevViewKey=null,t==null||this._dragging||window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;if(this._el.classList.contains("dfd-ai-assistant-layer-hidden")){this._cleanup();return}if(this._pendingExpectedAction){let n=ge(this._el);vr(this._pendingExpectedAction,n)&&(this._pendingViewChangeTimer&&clearTimeout(this._pendingViewChangeTimer),this._pendingViewChangeTimer=null,this._pendingExpectedAction=null)}let s=ge(this._el);if(i&&s&&i===s)return;let r=this._el.getBoundingClientRect().height;!Number.isFinite(r)||Math.abs(r-t)<1||this._animateHeight(t,r)}_cancelAnimation(){if(this._heightAnimation){try{this._heightAnimation.cancel()}catch(t){}this._heightAnimation=null}}_cleanup(){this._cancelAnimation(),this._pendingViewChangeTimer&&(clearTimeout(this._pendingViewChangeTimer),this._pendingViewChangeTimer=null),this._pendingExpectedAction=null,this._el.style.height="",this._el.style.overflow="",this._el.style.transition=""}_animateHeight(t,i){let s=this._el;s.style.overflow="hidden",s.style.transition="none",s.style.height=`${t}px`,s.offsetHeight,this._heightAnimation=s.animate([{height:`${t}px`},{height:`${i}px`}],{duration:300,easing:"cubic-bezier(0.4, 0.0, 0.2, 1)"});let r=()=>{this._heightAnimation=null,s.style.height="",s.style.overflow="",s.style.transition=""};this._heightAnimation.onfinish=r,this._heightAnimation.oncancel=r}};function ge(e){return e.querySelector(".dfd-ai-assistant-input-container")?e.querySelector("#dfd-ai-assistant-layer-content")?e.querySelector("#dfd-messages-list")?"history":e.querySelector("#dfd-single-message")?"single":e.querySelector(".dfd-ai-assistant-empty")?"empty":e.querySelector('[dfd-hook="AssistantLoading"]')?"loading":"unknown":"reduced":"collapsed"}function vr(e,t){switch(e){case"history-view":return t==="history";case"medium-view":return["single","empty","loading"].includes(t);case"reduced-view":return t==="reduced";case"collapsed-view":return t==="collapsed";case"close-layer":return!1;default:return!0}}function $o(e,t=300){!e||(e.style.transition=`height ${t}ms cubic-bezier(0.3, 0.0, 0.2, 1)`,setTimeout(()=>{e.style.transition="",e.style.height=""},t))}function Ah(e,t,i,s=0){if(!e)return;let r=120,n=.25,o=Math.max(40,s),a=l=>l<=r?l:r+(l-r)*n;if(t>0){let l=a(t);e.style.height=`${Math.max(o,i-l)}px`,e.style.transition="none"}else if(t<0){let l=a(-t);e.style.height=`${i+l}px`,e.style.transition="none"}}"use strict";var Vo={mounted(){this._animator=new _r(this.el);let e=0,t=0,i=null,s=0,r=0,n=50,o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent);this.el.addEventListener("touchstart",a=>{var d,f;let l=a.changedTouches[0];e=l.clientX,t=l.clientY,i=a.target;let h=this.el;if(h){s=h.offsetHeight;let b=h.querySelector(".dfd-ai-assistant-layer-header"),v=h.querySelector(".dfd-ai-assistant-input-container");r=((d=b==null?void 0:b.offsetHeight)!=null?d:0)+((f=v==null?void 0:v.offsetHeight)!=null?f:0)}this._animator.dragStart()},{passive:!0}),this.el.addEventListener("touchmove",a=>{o&&Hh(a);let{isHorizontal:l,deltaX:h,deltaY:d}=Ph(a,e,t),f=l?"x":"y";if(jo(i)){let g=a.changedTouches[0].clientY-t;this._animator.dragMove(this.el,g,s,r,Qi(this.el))}let b=Lh(i,a.target,this.el,f);if(!b){ti(a);return}if(Ih(b,f)){(l&&Rh(b,h)||!l&&Oh(b,d))&&ti(a);return}ti(a)},{passive:!1}),this.el.addEventListener("touchend",a=>{let l=this.el;if(i&&!jo(i)){this._animator.endDrag();return}let h=a.changedTouches[0],d=h.clientX-e,f=h.clientY-t,b=Math.abs(d),v=Math.abs(f),g=Qi(this.el)&&f<0;if(b>v||v<=n){this._animator.dragCancel(l,g?50:500);return}ti(a);let y=null;if(f>0)switch(!0){case Bo():document.getElementById("dfd-ai-assistant-input").blur();break;case Th():y="medium-view";break;case(Zi()&&!br()):y="reduced-view";break;case Xo():y="collapsed-view";break;case(Zi()&&br()&&xh()):y="reduced-view";break;case(Zi()&&br()):y="close-layer";break;default:y="medium-view";break}else switch(!0){case kh():y="medium-view";break;case Xo():y="medium-view";break;default:document.getElementById("dfd-ai-assistant-input").blur(),y=Qi(this.el)?null:"history-view";break}if(!this._animator.shouldDispatch(y)){this._animator.dragCancel(l,Qi(this.el)?50:300);return}this.pushEvent(y,{}),this._animator.actionDispatched(l,y)},!1)},beforeUpdate(){this._animator.beforeUpdate()},updated(){this._animator.updated()}};function Qi(e){return!!e.querySelector(".dfd-ai-assistant-empty")}function jo(e){return![".dfd-messages-list",".dfd-ai-assistant-suggestions",".dfd-compare-products"].some(i=>e.closest(i))}function Bo(){return window.innerHeights.clientWidth)return s}else if((r.overflowY==="auto"||r.overflowY==="scroll")&&s.scrollHeight>s.clientHeight)return s;s=s.parentElement}return null}function Ph(e,t,i){let s=e.changedTouches[0],r=s.clientX-t,n=s.clientY-i,o=Math.abs(r),a=Math.abs(n);return{deltaX:r,deltaY:n,isHorizontal:o>a}}function Lh(e,t,i,s){let r=qo(e||t,i,s);return r||(e&&t&&e!==t?qo(t,i,s):null)}function Ih(e,t){let i=getComputedStyle(e);return t==="x"?(i.overflowX==="auto"||i.overflowX==="scroll")&&e.scrollWidth>e.clientWidth:(i.overflowY==="auto"||i.overflowY==="scroll")&&e.scrollHeight>e.clientHeight}function Rh(e,t){let i=e.scrollLeft<=0,s=e.scrollLeft+e.clientWidth>=e.scrollWidth-1;return t>0&&i||t<0&&s}function Oh(e,t){let i=e.scrollTop<=0,s=e.scrollTop+e.clientHeight>=e.scrollHeight-1;return t>0&&i||t<0&&s}function ti(e){e.preventDefault(),e.stopPropagation()}function Hh(e){if(!Bo())return;let t=document.querySelector(".dfd-ai-input-textarea");if(!t)return;!(e.target&&e.target.closest(".dfd-ai-input-textarea"))&&document.activeElement===t&&t.blur()}"use strict";var Wo={mounted(){if(!window.visualViewport)return;let e=this.el.closest(".dfd-ai-assistant-layer");!e||!["dfd-ai-assistant-layer","dfd-ai-assistant-conversational-layer"].includes(e.id)||(this.syncWithKeyboard=()=>{let i=document.documentElement.clientHeight,s=i-(window.visualViewport.height+window.visualViewport.offsetTop);if(s>0)if(Dh()){let r=window.innerHeight-window.visualViewport.height+8;e.style.paddingBottom=`${r}px`}else e.style.bottom=`${s}px`,e.style.maxHeight=`${i-s}px`;else e.style.bottom="",e.style.paddingBottom="",e.style.maxHeight=""},window.visualViewport.addEventListener("resize",this.syncWithKeyboard),window.visualViewport.addEventListener("scroll",this.syncWithKeyboard),this.syncWithKeyboard())},updated(){this.syncWithKeyboard&&this.syncWithKeyboard()},destroyed(){window.visualViewport&&this.syncWithKeyboard&&(window.visualViewport.removeEventListener("resize",this.syncWithKeyboard),window.visualViewport.removeEventListener("scroll",this.syncWithKeyboard))}};function Dh(){let e=navigator.userAgent,t=e.match(/OS (\d+)_/);return/iPhone|iPad|iPod/.test(e)&&t&&Number(t[1])>=18}function Ko(){return/mobile/i.test(navigator.userAgent)}function zo(){return/iPhone|iPad|iPod/i.test(navigator.userAgent)}"use strict";var Jo={mounted(){this._preserved=null,this.isMobile=Ko(),this.getLineHeight=()=>{let e=document.createElement("div");e.style.position="absolute",e.style.visibility="hidden",e.style.height="auto",e.style.width=this.el.offsetWidth+"px",e.style.fontSize=window.getComputedStyle(this.el).fontSize,e.style.fontFamily=window.getComputedStyle(this.el).fontFamily,e.style.lineHeight=window.getComputedStyle(this.el).lineHeight,e.style.padding=window.getComputedStyle(this.el).padding,e.style.border=window.getComputedStyle(this.el).border,e.innerHTML="A",document.body.appendChild(e);let t=e.offsetHeight;return document.body.removeChild(e),t},this.scrollMessagesToBottom=()=>{let e=document.querySelector(".dfd-messages-list");e&&e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),this.isMobile||this.el.focus()},this.resize=()=>{this.el.style.height="auto";let e=this.el.scrollHeight,t=this.lineHeight*this.maxLines;e<=t?(e>0&&(this.el.style.height=e+"px"),this.el.style.overflowY="hidden"):(this.el.style.height=t+"px",this.el.style.overflowY="auto")},this.maxLines=4,this.originalHeight=this.el.scrollHeight,this.lineHeight=this.getLineHeight(),this.el.style.height="auto",this.el.style.overflowY="hidden",this.el.addEventListener("input",()=>this.resize()),this.el.addEventListener("change",()=>this.resize()),this.el.addEventListener("keyup",()=>this.resize()),this.el.addEventListener("paste",()=>{setTimeout(()=>this.resize(),0)}),this.el.addEventListener("keydown",e=>{if(e.key!="Enter"||e.shiftKey)return;e.preventDefault(),this.isMobile&&this.el.blur();let t=this.el.closest("form");if(t){let i=new Event("submit",{bubbles:!0,cancelable:!0});t.dispatchEvent(i)}}),this.handleEvent("set-textarea-value",e=>{e.id===this.el.id&&setTimeout(()=>{this.el.value=e.value,this.resize()},100)}),this.handleEvent("scroll-messages-to-bottom",()=>{this.scrollMessagesToBottom()}),this.handleEvent("set-assistant-textarea-focus",()=>{this.el.focus()}),this.resize()},beforeUpdate(){this._preserved={height:this.el.style.height,overflowY:this.el.style.overflowY}},updated(){this._preserved&&(this.el.style.height=this._preserved.height,this.el.style.overflowY=this._preserved.overflowY),this._preserved=null,this.resize()}};var ts=window.SpeechRecognition||window.webkitSpeechRecognition||null,Yo=["click"],Go=["start","end","error","result"],Mh="voice-search",Qo="voice-status-change";function Nh(e){return e.results.length>0?e.results[0][0].transcript:null}var Zo={mounted(){if(!ts){let e=window.isSecureContext===!0,t="SpeechRecognition"in window,i="webkitSpeechRecognition"in window;console.warn("VoiceSearch not supported: SpeechRecognition not available",{secureContext:e,hasSpeechRecognition:t,hasWebkitSpeechRecognition:i,userAgent:navigator.userAgent});return}this.recording=!1,this.query=null,this.driver=new ts,this.driver.continuous=!1,this.driver.interimResults=!1,this.handleVoiceEvent=e=>{switch(e.type){case"end":case"error":if(console.error("VoiceSearch event error",{error:e.error,message:e.message}),this.driver.stop(),this.recording=!1,this.pushEvent(Qo,{recording:!1}),this.query){let t=this.el.dataset.dfdEvent||Mh,i=this.el.getAttribute("dfd-target");i?this.pushEventTo(i,t,{query:this.query}):this.pushEvent(t,{query:this.query}),this.query=null}break;case"click":this.driver[this.recording?"stop":"start"](),this.recording=!this.recording,this.pushEvent(Qo,{recording:this.recording});break;case"result":{let t=Nh(e);t&&(this.query=t);break}}},Yo.forEach(e=>this.el.addEventListener(e,this.handleVoiceEvent)),Go.forEach(e=>this.driver.addEventListener(e,this.handleVoiceEvent))},destroyed(){Yo.forEach(e=>this.el.removeEventListener(e,this.handleVoiceEvent)),Go.forEach(e=>this.driver.removeEventListener(e,this.handleVoiceEvent))}};function J(e,t,...i){var o;let s=((o=i.find(a=>!!a.options))==null?void 0:o.options)||{},r={get tag(){return t},get options(){return s},debug(...a){H(`[hook][${e}]`,...a)}};return["mounted","beforeUpdate","updated","destroyed","disconnected","reconnected"].forEach(a=>{let l=i.map(h=>h[a]).filter(h=>!!h);r[a]=function(){l.length>0&&this.debug(`${a}()`),l.forEach(h=>h.call(this))}}),r}var ta={mounted(){this.el.addEventListener("keydown",e=>{e.target===this.el&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),document.getElementById(this.el.dataset.cardLinkId).click())})}};var ea={mounted(){this.el.addEventListener("click",e=>{let t=e.target.closest("[data-role]");t&&this.sendCustomEvent(t.dataset.role)}),this.getItem=()=>I(this,null,function*(){if(this._cardItemData)return Promise.resolve(this._cardItemData);let e={amount:1,filters:{}};return this.pushEventTo(`#${this.el.id}`,"get-item",e).then(t=>(this._cardItemData=t.item,this._cardItemData))}),this.getVariants=()=>I(this,null,function*(){return this._cardVariantsData?Promise.resolve(this._cardVariantsData):this.pushEventTo(`#${this.el.id}`,"load-variants",{}).then(e=>(this._cardVariantsData=e.variants,this._cardVariantsData))}),this.sendCustomEvent=e=>I(this,null,function*(){let t=`doofinder.card.${e}`,i=yield this.getItem(),s=yield this.getVariants(),r={item:i,variants:s,cardElement:this.el};document.dispatchEvent(new CustomEvent(t,{detail:r}))})}};"use strict";var ia={mounted(){if(this.btnLeft=this.el.querySelector("[dfd-carousel-btn-left]"),this.btnRight=this.el.querySelector("[dfd-carousel-btn-right]"),this.content=this.el.querySelector("[dfd-carousel-content]"),!!this.content){if(this.cardWidth=()=>{let e=this.content.firstElementChild;if(!e)return 247;let t=parseFloat(getComputedStyle(this.content).columnGap)||0;return e.getBoundingClientRect().width+t},this.updateArrows=()=>{if(!this.content)return;let{scrollLeft:e,scrollWidth:t,clientWidth:i}=this.content;i===0&&t===0||(this.btnLeft.disabled=e<=0,this.btnRight.disabled=Math.ceil(e)+i>=t)},this.scrollNext=()=>{this.content.scrollBy({left:this.cardWidth()*2,behavior:"smooth"})},this.scrollPrev=()=>{this.content.scrollBy({left:-this.cardWidth()*2,behavior:"smooth"})},this.btnLeft.addEventListener("click",this.scrollPrev),this.btnRight.addEventListener("click",this.scrollNext),this.content.addEventListener("scroll",this.updateArrows),window.matchMedia("(hover: hover)").matches){let e=!1,t=!1,i=0,s=0;this.onMouseDown=r=>{r.preventDefault(),e=!0,t=!1,i=r.pageX,s=this.content.scrollLeft,this.content.classList.add("dfd-is-dragging")},this.onMouseMove=r=>{if(!e)return;let n=r.pageX-i;Math.abs(n)>5&&(t=!0),this.content.scrollLeft=s-n},this.stopDrag=()=>{e=!1,this.content.classList.remove("dfd-is-dragging")},this.onClickCapture=r=>{t&&(r.stopPropagation(),r.preventDefault(),t=!1)},this.content.addEventListener("mousedown",this.onMouseDown),this.content.addEventListener("mousemove",this.onMouseMove),this.content.addEventListener("mouseup",this.stopDrag),this.content.addEventListener("mouseleave",this.stopDrag),this.content.addEventListener("click",this.onClickCapture,!0)}requestAnimationFrame(()=>this.updateArrows())}},updated(){requestAnimationFrame(()=>{var e;return(e=this.updateArrows)==null?void 0:e.call(this)})},destroyed(){var e,t,i,s,r,n,o,a;(e=this.btnLeft)==null||e.removeEventListener("click",this.scrollPrev),(t=this.btnRight)==null||t.removeEventListener("click",this.scrollNext),(i=this.content)==null||i.removeEventListener("scroll",this.updateArrows),(s=this.content)==null||s.removeEventListener("mousedown",this.onMouseDown),(r=this.content)==null||r.removeEventListener("mousemove",this.onMouseMove),(n=this.content)==null||n.removeEventListener("mouseup",this.stopDrag),(o=this.content)==null||o.removeEventListener("mouseleave",this.stopDrag),(a=this.content)==null||a.removeEventListener("click",this.onClickCapture,!0)}};"use strict";var sa={mounted(){this.clearLoader=()=>{this.aiTextInterval&&(clearInterval(this.aiTextInterval),this.aiTextInterval=null)},this.initializeLoader=()=>{let e=this.el.querySelector(".dfd-loading-dynamic-text"),t=this.el.querySelectorAll(".dfd-loading-icon");if(!e||t.length===0)return;let i=JSON.parse(e.dataset.texts||"[]");if(i.length===0)return;let s=0;this.aiTextInterval=setInterval(()=>{s=s+1,s{n===s?r.classList.add("active"):r.classList.remove("active")})):this.clearLoader()},2500)},this.initializeLoader()},updated(){if(this.el.classList.contains("hidden")){this.clearLoader();return}this.el.querySelector(".dfd-loading-dynamic-text")&&!this.aiTextInterval&&this.initializeLoader()},destroyed(){this.clearLoader()}};var ra={mounted(){this.autoScrollInterval=null,this.isUserInteracting=!1,this.scrollTimeout=null,this.initialDelay=null,this.currentScrollElement=0,this.suggestions=this.el.children,this.startAutoScroll=()=>{if(this.autoScrollInterval||this.isUserInteracting||document.hidden)return;let e=this.el.scrollWidth,t=this.el.clientWidth;e<=t+10||(this.autoScrollInterval=setInterval(()=>{let i=window.getComputedStyle(this.el).visibility==="hidden";this.isUserInteracting||i||(this.currentScrollElement==this.suggestions.length-1?this.currentScrollElement=0:this.currentScrollElement++,this.suggestions[this.currentScrollElement].scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}))},3e3))},this.stopAutoScroll=()=>{this.autoScrollInterval&&(clearInterval(this.autoScrollInterval),this.autoScrollInterval=null)},this.pauseAutoScroll=()=>{this.isUserInteracting=!0,this.stopAutoScroll()},this.resumeAutoScrollDelayed=()=>{this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.scrollTimeout=setTimeout(()=>{this.isUserInteracting=!1,this.startAutoScroll()},3e3)},this.onUserScroll=()=>{this.pauseAutoScroll(),this.resumeAutoScrollDelayed()},this.handleVisibilityChange=()=>{document.hidden?this.stopAutoScroll():this.isUserInteracting||this.startAutoScroll()},this.initialDelay=setTimeout(()=>{this.startAutoScroll()},2e3),this.el.addEventListener("touchstart",this.pauseAutoScroll.bind(this)),this.el.addEventListener("mouseenter",this.pauseAutoScroll.bind(this)),this.el.addEventListener("scroll",this.onUserScroll.bind(this)),this.el.addEventListener("click",this.pauseAutoScroll.bind(this)),this.el.addEventListener("touchend",this.resumeAutoScrollDelayed.bind(this)),this.el.addEventListener("mouseleave",this.resumeAutoScrollDelayed.bind(this)),document.addEventListener("visibilitychange",this.handleVisibilityChange.bind(this))},destroyed(){this.stopAutoScroll(),this.scrollTimeout&&clearTimeout(this.scrollTimeout),this.initialDelay&&clearTimeout(this.initialDelay),document.removeEventListener("visibilitychange",this.handleVisibilityChange.bind(this))}};"use strict";var na={mounted(){this.overlayElement=this.el.querySelector(".dfd-ai-assistant-contrast-overlay"),!!this.overlayElement&&(this.layerEl=this.el.querySelector(".dfd-ai-assistant-layer"),this.isInteracting=!0,this.handleEvent("focus-contrast-overlay",()=>{this.showOverlay()}),this.showOverlay=()=>{this.overlayElement.classList.add("dfd-ai-assistant-overlay-focused"),this.isInteracting=!0},this.hideOverlay=()=>{this.overlayElement.classList.remove("dfd-ai-assistant-overlay-focused"),this.isInteracting=!1},this.isInsideLayer=e=>!!this.layerEl&&!!e&&this.layerEl.contains(e),this.handleTouchStart=e=>{if(this.isInsideLayer(e.target)){this.showOverlay();return}this.isInteracting&&!this.isInsideLayer(e.target)&&this.hideOverlay()},document.addEventListener("touchstart",this.handleTouchStart,{passive:!0,capture:!0}))},updated(){let e=this.el.querySelector(".dfd-ai-assistant-contrast-overlay");e&&e!==this.overlayElement&&(this.overlayElement=e),!this.isInteracting&&this.overlayElement&&this.overlayElement.classList.remove("dfd-ai-assistant-overlay-focused")},destroyed(){this.overlayElement&&this.overlayElement.classList.remove("dfd-ai-assistant-overlay-focused"),document.removeEventListener("touchstart",this.handleTouchStart,!0)}};function oa(e){return JSON.parse(JSON.stringify(e))}function es(e,t,i){let s=i.x,r=s+i.width,n=i.y,o=n+i.height;return e>=s&&e<=r&&t>=n&&t<=o}function ei(e,t=!1){let i=Qs("__DF_LAYER_SERVER__")||`https://${e.toLowerCase()}-layer.doofinder.com`;return t?i.replace(/^http/,"ws"):i}function aa(){var e;if("maxTouchPoints"in navigator)return navigator.maxTouchPoints>0;if("msMaxTouchPoints"in navigator)return navigator.msMaxTouchPoints>0;{let t=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer:coarse)");if((t==null?void 0:t.media)==="(pointer:coarse)")return!!t.matches;if("orientation"in window)return!0;{let i=navigator.userAgent;return/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(i)||/\b(Android|Windows Phone|iPad|iPod)\b/i.test(i)}}}function yr(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));if(t)return decodeURIComponent(t[1])}function la(e){if(e instanceof PointerEvent)switch(e.pointerType){case"mouse":case"pen":case"touch":return!0;default:return!1}else if(e instanceof MouseEvent){let{pageX:t,pageY:i,target:s}=e;return!(t===i&&t===0&&Fh(s))}return!1}function Fh(e){return e.getAttribute("type")==="submit"&&(e.tagName==="BUTTON"||e.tagName==="INPUT")}function ha(e){return typeof e=="undefined"?null:e}var Sr=class{constructor(t){this._bubble=t,this._urlChangeHandler=null,this._initializeVisibility(),this._setupUrlChangeListener()}updateVisibility(){var t;!this._bubble||(((t=Doofinder.tools)==null?void 0:t.isCheckoutPage())?this._bubble.hide():this._bubble.show())}_initializeVisibility(){this.updateVisibility()}_setupUrlChangeListener(){var t;this._urlChangeHandler=()=>{this.updateVisibility()},(t=Doofinder.tools)==null||t.domObserver.observeURL(this._urlChangeHandler)}destroy(){var t;this._urlChangeHandler&&((t=Doofinder.tools)==null||t.domObserver.disconnect(this._urlChangeHandler),this._urlChangeHandler=null),this._bubble=null}};var Er=class{constructor(t){this.__options=t}get layout(){var t,i;return(i=(t=this.__options)==null?void 0:t.bubble_position)!=null?i:null}get verticalOffset(){var t,i;return(i=(t=this.__options)==null?void 0:t.bubble_vertical_offset)!=null?i:0}get layoutCSS(){switch(this.layout){case"bottom_right":return this._bottomRightCSS();case"bottom_left":return this._bottomLeftCSS();case"bottom_center":return this._bottomCenterCSS();case"right_center":return this._rightCenterCSS();default:return this._bottomRightCSS()}}_bottomRightCSS(){return` .dfd-chat-bubble { bottom: calc(${16+this.verticalOffset}px + env(safe-area-inset-bottom)); right: calc(16px + env(safe-area-inset-right)); } `}_bottomLeftCSS(){return` .dfd-chat-bubble { bottom: calc(${16+this.verticalOffset}px + env(safe-area-inset-bottom)); inset-inline-start: calc(16px + env(safe-area-inset-left)); flex-direction: row-reverse; display: flow; } .dfd-cta-wrapper { align-self: flex-start; margin-inline-end: auto; } `}_bottomCenterCSS(){return` .dfd-chat-bubble { display: flex; bottom: calc(${16+this.verticalOffset}px + env(safe-area-inset-bottom)); inset-inline-start: 50%; transform: translateX(-50%); align-items: center; } .dfd-cta-wrapper { align-self: flex-start; margin-inline-end: auto; } `}_rightCenterCSS(){return` .dfd-chat-bubble { top: calc(50% + ${16+this.verticalOffset}px); right: calc(16px + env(safe-area-inset-right)); transform: translateY(-50%); } `}};var wr=class{constructor(t,i){this.chatBubble=t,this.__timers=new Map,this.__ctaId="dfd-chat-bubble-cta",this.__messages=i.bubble_messages}get hashid(){return this.chatBubble.tag.hashid}get language(){return this.chatBubble.tag.language}get defaultMessage(){let t={en:"Need help? I'm your assistant",es:"\xBFNecesitas ayuda? Soy tu asistente.",de:"Brauchen Sie Hilfe? Ich bin Ihr Assistent!",fr:"Besoin d'aide? Je suis ton assistante.",it:"Hai bisogno di aiuto? Sono il tuo assistente."};return t[this.language]||t.en}get customMessage(){return this.__messages[this.hashid]}scheduleCallToAction(){let t=1e3*8,i=t+1e3*30,s=setTimeout(()=>{this.chatBubble&&this.createCallToAction()},t),r=setTimeout(()=>{this.chatBubble&&this.hide()},i);this.__timers.set("call-to-action",s),this.__timers.set("hide-call-to-action",r)}createCallToAction(){let t=this.customMessage||this.defaultMessage,i=`
${this.__closeIcon()}

${t}

`;this.chatBubble.trigger.insertAdjacentHTML("beforebegin",i);let s=o=>{o.preventDefault();let a=document.getElementById(this.__ctaId);a&&a.remove()},r=o=>{o.preventDefault();let a=document.getElementById(this.__ctaId);a&&(a.remove(),this.chatBubble.openConversationalLayer())};document.getElementById(this.__ctaId).addEventListener("click",r);let n=document.querySelector(".dfd-cta-wrapper .dfd-cta-close");n&&n.addEventListener("click",s)}hide(){let t=document.getElementById(this.__ctaId);t&&(t.remove(),this.clearTimers())}clearTimers(){["call-to-action","hide-call-to-action"].forEach(t=>this.clearTimer(t))}clearTimer(t){this.__timers.has(t)&&(clearTimeout(this.__timers.get(t)),this.__timers.delete(t))}destroy(){let t=document.getElementById(this.__ctaId);t!==null&&(t.remove(),t.clearTimers())}__closeIcon(){return` `}};function Cr(e){return e==="mobile"?"ai-mobile":"ai-fullscreen-conversational"}var ca="https://cdn.doofinder.com/ai_assistant/bubble_icons/default_bubble_icon.svg?v=3",Ar=class{constructor(t,i){this.__options=P({id:`dfd-chat-bubble-${Yt()}`,tag:t},i),this.isMobile=i.device=="mobile",this.bubbleSettings=i.bubble_settings,this.__setupLayoutManager(),this.__triggerSetup(this.__options),this.__layerEventsSetup(),this.bubbleSettings.bubble_message_enabled&&(this.__cta=new wr(this,this.__options),this.__cta.scheduleCallToAction()),this.__setupVisibilityManager()}__setupVisibilityManager(){this.__visibilityManager=new Sr(this)}__setupLayoutManager(){this.__layoutManager=new Er(this.bubbleSettings)}get tag(){return this.__options.tag}get trigger(){return this.__trigger}get bubbleIcon(){var i;let t=(i=this.bubbleSettings)==null?void 0:i.bubble_icon;return t||"https://cdn.doofinder.com/ai_assistant/bubble_icons/default_bubble_icon_white.svg?v=1"}show(){var t;(t=this.__wrapper)==null||t.removeAttribute("hidden")}hide(){var t,i;(t=this.__cta)==null||t.destroy(),(i=this.__wrapper)==null||i.setAttribute("hidden","")}destroy(){this.__wrapperTeardown(),this.__layerEventsTeardown(),this.__visibilityManager&&(this.__visibilityManager.destroy(),this.__visibilityManager=null)}conversationalLayer(){return Cr(this.__options.tag._device)}__layerEventsSetup(){this.__eventAbortController=new AbortController,document.addEventListener("doofinder.show",t=>{this.hide()},{signal:this.__eventAbortController.signal}),document.addEventListener("doofinder.hide",t=>{var i;((i=Doofinder.tools)==null?void 0:i.isCheckoutPage())||this.show(),sessionStorage.removeItem("dfd_ai_layer_trigger")},{signal:this.__eventAbortController.signal}),document.addEventListener("df:trigger:click",t=>I(this,null,function*(){if(this.tag._connection)try{yield this.tag._connectedPromise,this.tag._connection.pushEvent("change-screen")}catch(i){console.warn("Could not change screen:",i)}sessionStorage.removeItem("dfd_ai_layer_trigger")}),{capture:!0})}__layerEventsTeardown(){this.__eventAbortController&&(this.__eventAbortController.cancel(),delete this.__eventAbortController)}__triggerSetup({layerTrigger:t}){let i=this.__layoutManager.layoutCSS,s=document.createElement("style");s.appendChild(document.createTextNode(i)),document.head.appendChild(s);let r=document.createElement("div"),n=document.createElement("div");n.id=this.__options.id,n.classList.add("dfd-chat-bubble-trigger"),r.classList.add("dfd-chat-bubble");let o=document.createElement("template");o.innerHTML=this.__getBubbleIcon().trim(),n.appendChild(o.content.cloneNode(!0)),(t==null?void 0:t.backgroundColor)&&(n.style.backgroundColor=t.backgroundColor),(t==null?void 0:t.zIndex)&&(n.style.zIndex=t.zIndex),this.__wrapper=r,this.__trigger=n;let a=l=>I(this,null,function*(){l.preventDefault(),yield this.openConversationalLayer()});this.__trigger.addEventListener("click",a),r.append(n),document.body.append(r)}openConversationalLayer(){return I(this,null,function*(){var s;let t=Doofinder.getPageContext();((s=Doofinder.getApp("product_ai_assistant"))==null?void 0:s.length)>0&&t.pageType==="product"?(sessionStorage.setItem("dfd_ai_layer_trigger","chat_bubble"),yield Doofinder.AI.ProductAIAssistant.open()):(sessionStorage.setItem("dfd_ai_layer_trigger","chat_bubble"),yield this.tag.openAIAssistant())})}__customColorsApplied(){var t;if(this.__options.customProperties){let i=((t=this.__options.customProperties)==null?void 0:t.join(` `))||"";if(i=="")return!1;let s=`.data-svg-wrapper { ${i||""} }`,r=document.createElement("style");return r.appendChild(document.createTextNode(s)),document.head.appendChild(r),!0}return!1}__getBubbleIcon(){let t=this.__getBubbleBackgroundColor(),{bubble_icon:i,bubble_fill_color:s}=this.bubbleSettings||{},r=this.__buildIconContent(i,s);return`
${r}
`}__getBubbleBackgroundColor(){return this.bubbleSettings.bubble_background_color?this.bubbleSettings.bubble_background_color:this.__customColorsApplied()?"var(--df-accent-primary)":"#4285F4"}__buildIconContent(t,i){return t?``:i?` `:``}__wrapperTeardown(){var t,i;(t=this.__cta)==null||t.destroy(),(i=this.__wrapper)==null||i.remove(),delete this.__wrapper,delete this.__trigger}};var Uh="Search",da=aa(),ua="latestSearches",$h=10,Vh="dfd-root",is=class{constructor(t){this.__handleTriggerEvent__=this.__handleTriggerEvent__.bind(this),this.__handleLinkClick__=this.__handleLinkClick__.bind(this),this.__handleDocumentMousedown__=this.__handleDocumentMousedown__.bind(this),this.__handleDocumentKeyup__=this.__handleDocumentKeyup__.bind(this),this.__handleFocusTrap__=this.__handleFocusTrap__.bind(this),this.__updateSocketParams__=this.__updateSocketParams__.bind(this),this.__afterConnect__=this.__afterConnect__.bind(this),this.__afterDisconnect__=this.__afterDisconnect__.bind(this),this._triggerElement=null,this._preventOpen=!1;let{autoload:i,currency:s,device:r,exportResultsData:n,hashid:o,id:a,installationId:l,is_checkout:h,language:d,layout:f,layerType:b,search_query_retention:v,trigger:g,urlHash:y,zone:C}=t;this._installationId=l,this._zone=C,this._hashid=o,this._language=d,this._currency=s,this._exportResultsData=n,this._layerType=b,this._layout=f,this._device=r,this._browserLanguage=navigator.language||"",h&&this.dispatch("doofinder.layer.checkout",{url:window.location.href}),this._mount=this.__createMount__(a),this._mount.addEventListener("click",this.__handleLinkClick__),this._eventBus=new Ys(this._mount.id),this._eventBusSubscriptions=[tr,Ye,Ge,er].map(D=>this._eventBus.on(D,this.__handleTriggerEvent__)),this._trigger=g,this.__maybeResizeInputTrigger(),this._trigger.setEventBus(this._eventBus),this._display=new Js(this._mount),this._state=this.__defineNewState__(l,i,y,b),this._data=new We(`${l}.data`),this._params=this.__buildSocketParams__(t),this._hooks=this.__buildSocketHooks__(t),this._connection=null,this._connectedPromise=new At,this._theme=null,this._searchQueryRetention=v,this._urlHash=y,this._autoload=i,this.closable&&this.mount.classList.add("dfd-closable"),this._trigger.flushMessages(),this.__createChatBubble__({chat:t==null?void 0:t.chat,customProperties:t.custom_properties,layout:t.layout}),this.__loadState__().then(()=>this.dispatch("doofinder.ready"))}__createMount__(t){let i=document.createElement("div");return i.id=t||`df-${Yt(32)}`,i.dataset.dfdView=Uh,i.setAttribute(Ut,""),i.classList.add(Vh),Object.defineProperty(i,"doofinderTag",{value:this,writable:!1}),i}get mount(){return this._mount}get trigger(){return this._trigger}get display(){return this._display}get hashid(){return this._hashid}get installationId(){return this._installationId}get zone(){return this._zone}get language(){return this._language}get currency(){return this._currency}get exportResultsData(){return this._exportResultsData}get layerType(){return this._layerType}get searchQueryRetention(){return this._searchQueryRetention}get data(){return this._data}get state(){return this._state}get closable(){return this.display.type!==de||!this._state.hasAutoloadQueryParam}set targetItemId(t){this.state.targetItemId=t}enableDebug(){return this._connection?(this._connection.enableDebug(),!0):!1}debug(...t){H("[tag]",...t)}updateState({value:t=this._state.value,itemId:i=this._state.targetItemId,isTransitory:s=this._state.isTransitory}){this._state.update(t,i,s)}__handleTriggerEvent__(t){if(this._preventOpen)return;let{source:i,originalEvent:s}=t.detail,{query:r}=t.detail,n=r?{query:r}:{};this.connect(n).then(()=>{var o;if(this.__shouldDisplay__(t)){((o=this._display)==null?void 0:o.hidden)&&this.show(i),t.type===Ge&&this.search(r);return}t.type===er&&this.submit(r,a=>{var h;if(!a){this.show(i);return}let{submit:l}=a||{};l&&((h=s==null?void 0:s.target.closest("form"))==null||h.submit())})})}__shouldDisplay__(t){let{query:i,source:s={}}=t.detail,{tagName:r,role:n}=s,o=r==="BUTTON"||n==="button";switch(this._display.type){case Li:return(t.type===Ge||t.type===Ye)&&(this._display.screenType==="classic-initial"||!!i);case de:return(t.type===Ge||t.type===Ye)&&!!i;case Ke:case ze:return t.type===tr||t.type===Ye&&!o;default:return!1}}__handleLinkClick__(t){var r,n;if(this.dispatch("doofinder.layer.click",{originalEvent:t}),t.target.href===window.location.href){t.preventDefault(),this.__closeAndPreserveQuery__();return}if(!t.target.href){(r=this._connection)==null||r.setPreventReconnect(!1);return}let i=t.target.closest("[dfd-value-dfid]"),s=i==null?void 0:i.getAttribute("dfd-value-dfid");s&&this.updateState({itemId:s}),(n=this._connection)==null||n.setPreventReconnect(!0),this._layerType!=="category_pages"&&this._searchQueryRetention&&this._state.saveTransitory(t.target.href)}__closeAndPreserveQuery__(){if(this.searchQueryRetention){let t=this._state.query;setTimeout(()=>{this._trigger.updateQuery(t)},300)}this.close()}__handleDocumentMousedown__(t){let{clientX:i,clientY:s}=t,r=this._mount.querySelector("dialog:modal");if(r==null?void 0:r.open){es(i,s,r.getBoundingClientRect())||r.close();return}if(this._display.hidden||this._display.type===de||!la(t)||es(i,s,this._mount.getBoundingClientRect()))return;let n=this._display.method.positionReference;!!n&&(es(i,s,n.getBoundingClientRect())||t.target.closest('button[type="submit"]')&&t.target.closest("form")===n.closest("form"))||this.close()}__handleDocumentKeyup__(t){var i;if(t.key==="Escape"){let s=this._mount.querySelector("dialog:modal");if(s==null?void 0:s.open){s.close();return}this.layerType!=="category_pages"&&((i=document.activeElement)==null||i.blur(),this.close())}}__loadState__(){return this._layerType==="category_pages"||(this.debug("load state:",this._state.value),this._trigger.updateQuery(this._searchQueryRetention?this._state.query:""),!this._state.value)?Promise.resolve():this._state.isTransitory?(H("didn't load the state because it is transitory"),Promise.resolve()):this.connect({state:this._state.value}).then(()=>this.show())}getLatestSearches(){return this._data.getItem(ua)||[]}updateLatestSearches(t){this._data.setItem(ua,t)}onLoad(t){let{min_capture_length:i,capture_submit:s,align:r,display_type:n,insertion_point:o,insertion_method:a,screen_type:l,theme:h}=t;this.__updateTrigger__({min_capture_length:i,capture_submit:s}),this.__updateDisplay__({display_type:n,insertion_point:o,insertion_method:a,screen_type:l,theme:h,align:r}),this._connectedPromise.resolve(t)}__updateTrigger__({min_capture_length:t,capture_submit:i}){this._trigger.setCaptureLength(t),this._trigger.captureSubmit=i}__updateDisplay__({display_type:t,insertion_point:i,insertion_method:s,screen_type:r,theme:n,align:o}){this._display.setType(t,{placement:{insertionPoint:i,insertionMethod:s},align:o}),this._display.screenType=r,this._display.updateTheme(n),this._display.hidden||this.updatePosition()}__createChatBubble__({chat:t,customProperties:i,layout:s}){if(t&&"bubble_settings"in t&&t.bubble_settings[this._device]&&Pn.includes(s)){let r=t.bubble_settings[this._device];r.bubble_enabled&&(this._bubble=new Ar(this,{device:this._device,bubble_settings:r,bubble_messages:(t==null?void 0:t.bubble_messages)||{},customProperties:i}))}}updatePosition(t){return I(this,null,function*(){this._display.updatePosition({positionReference:t||(yield this._trigger.getElement())})})}close(){var t,i;this.closable&&((i=(t=this.getHooksByName("Layer"))==null?void 0:t.pop())==null||i.close())}show(t){return I(this,null,function*(){this.__isModalLayer__()&&this._display.hidden&&(this._triggerElement=document.activeElement),yield this.updatePosition(t),yield this._display.show(),this.__isModalLayer__()&&this.__applyModalAccessibility__(),this.updateState({isTransitory:!1}),(this.state.targetItemId!==null||this.state.startPage>1)&&setTimeout(()=>{var i;return(i=this._connection)==null?void 0:i.pushEvent("update-scroll",{page:this.state.startPage,dfid:this.state.targetItemId})},200),this.dispatch("doofinder.show")})}hide(){return I(this,null,function*(){this._display&&(yield this._display.hide()),this.dispatch("doofinder.hide")})}dispatch(t,i={}){let s=Z(P({},i),{tag:this});document.dispatchEvent(new CustomEvent(t,{detail:s}))}connect(t){return this._connection||(this.debug(`creating live socket for layer: ${this._mount.id}`),this._connection=new Us(this.__connectionSetup__(t)),this._connection.connect(this.__afterConnect__)),this._connectedPromise}isConnected(){return this._connection?this._connection.connected:!1}open(){return I(this,arguments,function*(t={}){let{search:i,screen:s}=t,r=P({},t);i!=null&&!s&&(r.screen="fallback"),typeof i=="string"&&(delete r.search,r.query=i),yield this.connect(r),yield this.show(),typeof i=="object"&&this.search(i)})}openAIAssistant(){return I(this,null,function*(){var n;let t=Cr(this._device),i={screen:t},s=Doofinder.getPageContext();if(((n=Doofinder.getApp("product_ai_assistant"))==null?void 0:n.length)>0&&s.pageType=="product"&&this._device=="mobile"){let o=yield s.dfidPromise,a=window.location.href;yield this.connect({screen:t,dfid:o,current_url:a})}else yield this.connect(i);yield this.show()})}__getPageFromUrl__(){let t=new URLSearchParams(window.location.search).get("dfpage");if(t==null)return null;let i=parseInt(t,10);return Number.isInteger(i)&&i>=1?i:null}openCategoryPages(t){return I(this,null,function*(){let{search:i}=t,s={search:i},r=this.__getPageFromUrl__();if(r!=null){s.search=Z(P({},i),{page:r});let o=new URL(window.location.href);o.searchParams.delete("dfpage"),window.history.replaceState({},"",o)}let n=this._state.value;n&&(s.state=n),H("[category pages] connect with",s),yield this.connect(s),yield this.show(),n||(H("[category pages] no state, opening with: ",s.search),this.search(s.search))})}disconnect(){var t;this.layerType!=="category_pages"&&(this.debug(`disconnecting from live socket: ${this._mount.id}`),this._trigger.updateQuery(""),this.updateState({value:"",itemId:null,isTransitory:!1}),this.__removeModalAccessibility__(),this.hide(),(t=this._connection)==null||t.disconnect(this.__afterDisconnect__),this._connection=null,this._triggerElement&&(this._preventOpen=!0,this._triggerElement.focus(),this._preventOpen=!1,this._triggerElement=null),this._connectedPromise=new At)}destroy(){return I(this,null,function*(){var t,i;this.debug(`destroy: ${this._mount.id}`),this.__removeModalAccessibility__(),this._triggerElement=null,this.hide(),(t=this._connection)==null||t.disconnect(this.__afterDisconnect__),this._connection=null,(i=this._bubble)==null||i.destroy(),this._bubble=null,this._eventBusSubscriptions.forEach(s=>s()),this._eventBusSubscriptions=null,this._eventBus.teardown(),this._eventBus=null,yield this._display.destroy(),this._display=null,this._trigger.destroy(),this._mount.replaceChildren(),this.dispatch("doofinder.destroy")})}getHooksByName(t){var i;return(i=this._connection)==null?void 0:i.getHooksByName(t)}search(t,i){var r;let s=typeof t=="string"?{query:t}:t;(r=this._connection)==null||r.pushEvent("search-suggest",{search:s},i)}changeLocale(t,i,s){var r;(r=this._connection)==null||r.pushEvent("change-locale",{language:t,currency:i},s)}submit(t,i){var s;(s=this._connection)==null||s.pushEvent("search-submit",{search:{query:t}},i)}updateLastActivity(){var i,s,r;let t=(s=(i=this._connection)==null?void 0:i.liveSocket)==null?void 0:s.socket.isIdle();H("update last activity. idle?:",t),(r=this._connection)==null||r.pushEvent("update-last-activity",{idle:t})}__buildSocketParams__(t){let{params:i,sort:s,vars:r,indices:n,state:o,priceName:a,hidePrices:l}=t,h={hashid:this._hashid,origin:window.location.hostname,indices:n,params:i,sort:s,vars:r,state:o,price_name:a,hide_prices:l,timezone_offset:new Date().getTimezoneOffset()};return["indices","search-server"].filter(d=>!h[d]).forEach(d=>delete h[d]),h}__buildSocketHooks__(t){let i=t.hooks||{},s={Carousel:J("Carousel",this,Fn,i.Carousel||{}),ImageSearch:J("ImageSearch",this,Zn),Input:J("Input",this,io,i.Input||{}),Layer:J("Layer",this,ho,fo,this.layerType==="category_pages"&&this._device==="mobile"?mo:{},this.layerType==="category_pages"?uo:{},i.Layer||{}),LayerNotAvailable:J("LayerNotAvailable",this,co),AddToCart:J("AddToCart",this,so,i.AddToCart||{}),AssistantLoading:J("AssistantLoading",this,sa,i.AssistantLoading||{}),SuggestionsAutoScroll:J("SuggestionsAutoScroll",this,ra,i.SuggestionsAutoScroll||{}),ContrastOverlay:J("ContrastOverlay",this,na,i.ContrastOverlay||{}),EmbeddedResults:J("EmbeddedResults",this,hr,dr,da?cr:{},i.EmbeddedResults||{}),Results:J("Results",this,hr,da?cr:{},dr,i.Results||{}),SimilarResults:J("SimilarResults",this,So,i.SimilarResults||{}),Slider:J("Slider",this,Fo,i.Slider||{}),Swipe:J("Swipe",this,Uo,i.Swipe||{}),MobileSwipe:J("MobileSwipe",this,Vo,i.MobileSwipe||{}),KeyboardOffset:J("KeyboardOffset",this,Wo,i.KeyboardOffset||{}),Textarea:J("Textarea",this,Jo,i.Textarea||{}),VoiceSearch:J("VoiceSearch",this,Zo,i.VoiceSearch||{}),CardTabNavigation:J("CardTabNavigation",this,ta,i.CardLink||{}),CardLive:J("CardLive",this,ea,i.CardLive||{}),FashionCardCarousel:J("FashionCardCarousel",this,Xn,i.FashionCardCarousel||{}),FashionCardOverlay:J("FashionCardOverlay",this,Yn,i.FashionCardOverlay||{}),FashionCarousel:J("FashionCarousel",this,ia,i.FashionCarousel||{})};return H("[tag] Hooks created:",this._mount.id,s),Object.keys(i).filter(r=>!s[r]).forEach(r=>{s[r]=J(r,this,i[r]||{})}),s}__connectionSetup__(t){return{url:`${ei(this._zone,!0)}/layer/${pe}`,mount:this._mount,hooks:this._hooks,mainHook:"Layer",params:()=>this.__updateSocketParams__(t),appName:"layer",disconnectCallback:(()=>{this.debug("layer died and can't reconnect automatically! \u{1F92C}"),this.__afterDisconnect__()}).bind(this)}}__updateSocketParams__(t){var s,r,n;let i=Z(P({},oa(this._params)),{zone:this.zone,installation_id:this.installationId,language:this.language,currency:this.currency,session_id:Doofinder.Session.getSessionId(),tab_id:"getTabId"in Doofinder.Session?Doofinder.Session.getTabId():null,session_alive:Doofinder.Session.isLive("layer"),conversation_id:Tn("conversation_id"),user_id:Doofinder.Session.getUserId(),results_personalization_dfids:"getLatestDfids"in Doofinder.Session?Doofinder.Session.getLatestDfids(this._hashid):[],latest_searches:this.getLatestSearches(),voice_supported:!!ts,export_results_data:Array.isArray(this.exportResultsData)?this.exportResultsData.slice(0,$h):null,ga_client_id:ha((s=yr("_ga"))==null?void 0:s.substring(6)),layer_type:this.layerType,state:this._state.value,mount_id:this._mount.id,current_url:window.location.href,ai_layer_trigger:sessionStorage.getItem("dfd_ai_layer_trigger"),browser_language:this._browserLanguage});return this._layerType==="category_pages"&&(i.search=t.search),((r=this._connection)==null?void 0:r.connected)||(i=P(P({},i),t)),this.debug(`__updateSocketParams__ for layer: ${this._mount.id}`,i," socket connected? ",(n=this._connection)==null?void 0:n.connected," overrides: ",t," current state",this._state.value),i}__afterConnect__(){document.addEventListener("mousedown",this.__handleDocumentMousedown__),document.addEventListener("keyup",this.__handleDocumentKeyup__,{passive:!0})}__afterDisconnect__(){document.removeEventListener("keyup",this.__handleDocumentKeyup__),document.removeEventListener("mousedown",this.__handleDocumentMousedown__),this.dispatch("doofinder.disconnect")}__defineNewState__(t,i,s,r){return new fe({installationId:t,autoload:i,urlHash:s,layerType:r})}__isModalLayer__(){return this.closable&&this._display&&[ze,Ke,Pi].includes(this._display.type)}__applyModalAccessibility__(){let t=this._mount.querySelector(".dfd-layer");t&&(t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Search"));let i=this._mount.parentElement;if(i)for(let r of i.children)r!==this._mount&&!r.hasAttribute("aria-hidden")&&(r.setAttribute("aria-hidden","true"),r.setAttribute("data-dfd-aria-hidden",""));document.addEventListener("keydown",this.__handleFocusTrap__);let s=this._mount.querySelector(".dfd-searchbox-input");s&&setTimeout(()=>s.focus(),0)}__removeModalAccessibility__(){document.querySelectorAll("[data-dfd-aria-hidden]").forEach(t=>{t.removeAttribute("aria-hidden"),t.removeAttribute("data-dfd-aria-hidden")}),document.removeEventListener("keydown",this.__handleFocusTrap__)}__handleFocusTrap__(t){to(t,this._mount)}__maybeResizeInputTrigger(){var s;if(this._layout!=="AIFullscreen"||this._device!=="mobile"||!zo())return;let t=(s=this._trigger)==null?void 0:s._element;if(!(t instanceof HTMLInputElement))return;let i=parseFloat(window.getComputedStyle(t).fontSize||"0");(!isFinite(i)||i<16)&&t.style.setProperty("font-size","16px","important")}};var jh=Object.freeze({language(e){let t=(e==null?void 0:e.replaceAll("_","-").trim().split("-"))||[];function i(s){return s?`-${s.toUpperCase()}`:""}if(t.length<3){let[s,r]=t;return`${s==null?void 0:s.toLowerCase()}${i(r)}`}else{let[s,r,n]=t;return`${s==null?void 0:s.toLowerCase()}-${r.toUpperCase()}${i(n)}`}},currency(e){return e==null?void 0:e.trim().toUpperCase()}});function Tr(e){return I(this,null,function*(){let t=document.createElement("style");t.appendChild(document.createTextNode((e||"").trim())),document.head.appendChild(t)})}function fa(e){return I(this,null,function*(){var o;let t=Xh(e);H("[category pages] displayForSeo options: ",e,"params: ",t);let i=yield qh(t);if(H("[category pages] displayForSeo htmlContent: ",i),!i)return;let s=Bh(e.id,i);e.device=="mobile"&&(s.classList.remove("dfd-embedded"),s.classList.add("dfd-mobile_embedded")),e.custom_css.forEach(Tr);let r=(o=e.custom_properties)==null?void 0:o.join(` `);Tr(`#${s.id} { ${r||""} }`);let n=document.querySelector(e.insertion_point);H("[category pages] displayForSeo insertion point: ",n),n&&n.replaceWith(s)})}function Bh(e,t){let i=document.createElement("div");return i.id=e||`df-${Yt(32)}`,i.dataset.dfdView="Search",i.classList.add("dfd-root"),i.insertAdjacentHTML("afterbegin",t),i}function Xh(e){let{installationId:t,hashid:i,language:s,currency:r,zone:n,search:o,sort:a,urlHash:l,vars:h,layerType:d,autoload:f,priceName:b,hidePrices:v}=e,g=Doofinder.Session.getSessionId(),y=Doofinder.Session.getUserId(),C=new fe({installationId:t,autoload:f,urlHash:l,layerType:d}).value,D=new URLSearchParams(window.location.search).get("dfpage"),R=D?parseInt(D,10):null,x=Number.isInteger(R)&&R>1?Z(P({},o),{page:R}):o;return{installationId:t,hashid:i,language:s,currency:r,zone:n,state:C,search:x,sort:a,price_name:b,hide_prices:v,session_id:g,user_id:y,vars:h,current_url:window.location.href}}function qh(e){return I(this,null,function*(){let{zone:t}=e,i=ei(t),s=new URL(`${i}/api/${pe}/categorypage`);return Object.keys(e).forEach(function(n){let o=e[n];typeof o=="undefined"||o==null||(typeof o=="object"&&(o=JSON.stringify(o)),s.searchParams.append(n,o))}),yield fetch(s).then(function(n){return n.ok?n.text():""})})}function pa(e){let{hashid:t,url_patterns:i}=e,s=window.location.origin+window.location.pathname;return H("[category merchandising] URL patterns: ",i," URL: ",s),Wh(t,i,s)}function Wh(e,t,i){try{let s=Kh(e,t,i);if(!s)return H("[category merchandising] configuration not found for current location, urlStr: ",i),null;let r=ma(s),n=[...i.matchAll(r)][0].groups,o=zh(s,n);return o.url_pattern_id=s.id,H("[category merchandising] configuration found for current location, urlStr: ",i,"URLPattern: ",s,"capturedValues from URL: ",n,"params to open the layer: ",o),o}catch(s){return H("[category merchandising] error trying to get category merchandising search options: ",s),null}}function Kh(e,t,i){return t.filter(s=>s.hashid===e).find(s=>{let r=ma(s);return[...i.matchAll(r)].length>0})}function ma(e){let[,,t,i]=e.pattern.match(/(\/?)(.+)\1([a-z]*)/i);i=i||"g";let s=new RegExp(t,i);return H("pattern ",t,"flags",i,"regexp",s),s}function zh(e,t){let i="{{",s="}}",{params:r}=e,n=JSON.stringify(r.search);for(let o in t){let a=`${i}${o}${s}`,l=t[o];H("[category merchandising] replacing old value: ",a,", new value ",l,"at",n),n=n.replaceAll(a,l)}return JSON.parse(n)}var ss=[];document.addEventListener("doofinder.destroy",e=>{ss=ss.filter(t=>t!==e.detail)});var ga={getTags(){return ss.slice(0)},create(e){let t=new is(e);return e.layerType==="category_pages"&&(e.search=pa(e),e.search&&(fa(e),t.openCategoryPages(e))),ss.push(t),t},destroy(e){var t;e instanceof is?e.destroy():(t=e==null?void 0:e.doofinderTag)==null||t.destroy()},enableDebug:Rn,disableDebug:On,debug:H,utils:{buildNumericFormatter:zi,buildCurrencyFormatter:Ki}};Object.defineProperty(ga,"__version__",{value:pe});Vr($r,ga);})();